You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by "Lewis G. Pringle, Jr." <le...@RecordsForLiving.com> on 2007/06/22 16:26:18 UTC

How do I run XSLT on a Xerces document?

I'm using Xerces-C 2.7.0, and Xalan-C 1.10.0.

 

I have a source document and an XSLT script already parsed as Xerces
DOMDocument objects, and I wish to do a simple transform () (like the msxml
transformNode() call).

 

My code reads something like this (note - all xerces/Xalan inits done
elsewhere):

 

            wstring  f (DOMDocument* llStylesheetDoc, DOMDocument* llSrcDoc)

            {

                        XercesParserLiaison      parserLiason;

                        XalanTransformer          theXalanTransformer;

 

                        XSLTInputSource xmlIn(parserLiason.createDocument
(llSrcDoc));

                        XSLTInputSource xslIn(parserLiason.createDocument
(llStylesheetDoc));

                        XSLTResultTarget xmlOut("foo-out.xml");

                        int theResult =
theXalanTransformer.transform(xmlIn,xslIn,xmlOut);    

                        ...

            }

 

 

The XercesParserLiaison part appears to be working properly and produces a
XalanNode*. The trouble is that the XalanTarnsformer::transform() calls
parseSource (), which calls XalanDefaultParsedSource::create () - which -
digging down deep enough - eventually creates a SAX parser and tries to
create an INPUT reader/stream associated with the input source, gets null,
and throws out.

 

Any hints about what I'm doing wrong?

 

                        Thanks,

                                                Lewis.

 


Re: How do I run XSLT on a Xerces document?

Posted by David Bertoni <db...@apache.org>.
Lewis G. Pringle, Jr. wrote:
> I’m using Xerces-C 2.7.0, and Xalan-C 1.10.0.
> 
> I have a source document and an XSLT script already parsed as Xerces 
> DOMDocument objects, and I wish to do a simple transform () (like the 
> msxml transformNode() call).
> 
> My code reads something like this (note – all xerces/Xalan inits done 
> elsewhere):
>

...

> 
>                         XSLTInputSource 
> xmlIn(parserLiason.createDocument (llSrcDoc));

This is a legacy option with an InputSource to use a generic DOM node. 
Instead, you can use XercesDOMWrapperParsedSource:

XercesDOMWrapperParsedSource xmlIn(llSrcDoc, parserLiaison, domSupport);

Dave