You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Scott Boag/CAM/Lotus <Sc...@lotus.com> on 2000/01/18 22:33:52 UTC

RE: xslt with existing DOM nodes: HIERARCHY_REQUEST_ERR

> Is this spec'd
> behavior?

No.  You should be able to apply the transformation from within anywhere in
the source tree.

This normally happens when trying to add text to the root node of the
document, which produces the error from within the xerces code.  Is it
possible the change in the start context could effect this?

-scott




                                                                                                                   
                    Brian Dupras                                                                                   
                    <briand@cente        To:     "'general@xml.apache.org'" <ge...@xml.apache.org>               
                    ra.com>              cc:     (bcc: Scott Boag/CAM/Lotus)                                       
                                         Subject:     RE: xslt with existing DOM nodes: HIERARCHY_REQUEST_ERR      
                    01/18/00                                                                                       
                    04:15 PM                                                                                       
                    Please                                                                                         
                    respond to                                                                                     
                    general                                                                                        
                                                                                                                   
                                                                                                                   




> The error I get now is:
>  "org.apache.xerces.dom.DOMExceptionImpl: HIERARCHY_REQUEST_ERR"

Found the trouble: It seems that I can only perform a transform against the
whole document, not just a single node and its children.  Is this spec'd
behavior?

Brian

> -----Original Message-----
> From: Brian Dupras [mailto:briand@centera.com]
> Sent: Tuesday, January 18, 2000 9:59 AM
> To: Xml-Apache (E-mail)
> Subject: xslt with existing DOM nodes: HIERARCHY_REQUEST_ERR
>
>
> Thanks for all the help I'm getting here with the apache xml/xsl
> implementations.
>
> I'm trynig to get (xml Node) + (xsl Node) => (xml Node)
> working, but I keep
> getting an error.  Thanks Scott for the XercesLiaison() fix -
> it got me half
> way.
>
> The error I get now is:
>  "org.apache.xerces.dom.DOMExceptionImpl: HIERARCHY_REQUEST_ERR"
>
> I'm sending in two DOM nodes and want to receive a DOM node in return.
> Following is a sample.
>
> Brian
>
>
> Code snippets:
>
> private Element processElement(Element xmlelemTarget,
>                                Element xmlelemXSLT)
>                                throws SAXException
> {
>          Document xmldocResult = new DocumentImpl();
>          xsltProcessor.process(         new
XSLTInputSource(xmlelemTarget),
>                                                   new
> XSLTInputSource(xmlelemXSLT),
>                                                   new
> XSLTResultTarget(xmldocResult)
>                                                   );
>          return xmldocResult.getDocumentElement();
> }
>
>
> domParser =
> (DOMParser)Class.forName("org.apache.xerces.parsers.DOMParser"
> ).newInstance(
> );
>
> xsltProcessor = XSLTProcessorFactory.getProcessor(new
> org.apache.xalan.xpath.xdom.XercesLiaison());
>
>
> thexml = parser.parse(fname).getDocument().getDocumentElement();
> thexsl = parser.parse(fname).getDocument().getDocumentElement();
>
> NodeList nl = thexml.getElementsByTagName("component");
> ...
> thexmlElement = (Element)nl.item(i);
>
> //throws exception HIERARCHY_REQUEST_ERR:
> Element result = processElement(thexmlElement, thexsl);
>
>
>
>
>
> The xml Node (Element) looks like this:
> <component>
>   <resource rid='abdcedfghi127_nons'/>
>   <type rid='abdcedfghi002_nons'/>
>   <params/>
> </component>
>
>
> The xsl Node (Document Element) looks like this:
> <?xml version="1.0"?>
>
> <xsl:stylesheet
>          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>          xmlns:pp="http://medwired.com/namespaces/practiceportal/1.0"
>          xmlns:xlink='http://www.w3.org/XML/XLink/0.9'
>          exclude-result-prefixes="pp xlink"
>          >
>          <xsl:output method="xml" indent="yes"
> omit-xml-declaration="yes" />
>
>          <span>
>                    testing
>          </span>
> </xsl:stylesheet>
>
>
> Brian Dupras
> Centera Information Systems, Inc.
> phone         303.939.0200 x294
> fax           303.939.0111
> web           http://www.centera.com
> email         briand@centera.com
>