I am having an issue with output of data when I perform a
transformation.

I am attempting to do a DOMSource to DOMResult transformation. My
stylesheet has the xml:output property set to "xml".

Currently when that runs I get a DOMException:

javax.xml.transform.TransformerException: org.w3c.dom.DOMException:
HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is
not permitted. 

This led me to think there was something wrong with the output which I
discovered by changing to a StreamSource and dumping to System.out:

<?xml version="1.0" encoding="UTF-8"?>fieldValue fieldValue2 ...

I would think I had something wrong with my stylesheet but I have two
reasons that make me think I have a xalan configuration error some
obscure defect.

1) The output of fieldValue fieldValue2 comes from my stylesheet which
should be wrapped in XML elements.

2) When I run the same code using SAXON 6.5.5 I get the output I am
expecting, eg:

<?xml version="1.0"
encoding="UTF-8"?<root><firstElement>fieldValue</firstElement></secondEl
ement>fieldValue2</secondElement>...

My transformer code is completely standard:

public Document transform(Document document) {
  Source requestSource = new DOMSource(document);
  URL url = this.getClass()getResource("stylesheet.xsl");
  Source stylesheet = new StreamSource(url.toString());
  Transformer transformer =
TransformerFactory.newInstance().newTransformer(stylesheet);
  Document resultDocument =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  transformer.transform(requestSource, new DOMResult(resultDocument));
  Return resultDocument;
}

I have done exhaustive digging into this and am at a complete loss. It
seems like Xalan is using the text output method but I have explicitly
named the xml method type. Does anyone have any idea what would cause
Xalan to behave in this way?

Thank you in advance for your help.

Peter

E-MAIL CONFIDENTIALITY NOTICE:  The contents of this e-mail message and any 
attachments are intended solely for the
addressee(s) and may contain confidential and/or legally privileged 
information. If you are not the
intended recipient of this message or if this message has been addressed to you 
in error, please
immediately alert the sender by reply e-mail and then delete this message and 
any attachments. If you
are not the intended recipient, you are notified that any use, dissemination, 
distribution, copying, or
storage of this message or any attachment is strictly prohibited.

Reply via email to