What I actually want to do is the following:-

 1. Validate the original XML.
 2. Transform the XML.
 3. Use the resulting nodes in the application - I don't want to send
the results to a stream.

Is there a useage pattern for this?

Thanks

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 30 April 2003 16:51
To: xalan-c-users@xml.apache.org
Subject: RE: problem with XSLT tranformation using Xalan






Hi Michael,

Please download Xalan-C++ 1.5.  It has support for the new Xerces DOM.
The old DOM is now deprecated because the performance of the new DOM is
much better.

Just to re-iterate here -- it looks like you're using the Xerces DOM for
the sake of using it, not because you need to.  Make sure that between
the time you parse the document, and the time you do the transformation,
that you're actually going to modify the DOM instance in some way.
Otherwise, you are much better off just letting Xalan parse the
document.

Dave



 

                      "Michael Hughes"

                      <michael.hughes@         To:
<xalan-c-users@xml.apache.org>

                      gf-x.com>                cc:      (bcc: David N
Bertoni/Cambridge/IBM)                                      
                                               Subject: RE: problem with
XSLT tranformation using Xalan                           
                      04/30/2003 07:41

                      AM

 




Please correct me if I'm wrong, but the useage pattern you referred to
is the following...

#include <parsers/DOMParser.hpp>
#include <XalanTransformer/XercesDOMWrapperParsedSource.hpp>

void parseWithXerces(XalanTransformer &xalan,
                     const XSLTInputSource &xmlInput,
                     const XalanCompiledStylesheet* styleSheer,
                     const XSLTResultTarget &output,
                     XMLFileReporter &logFile)
{
    XercesDOMParser theParser;

    // Turn on validatiion and namespace support.
    theParser.setDoValidation(true);
    theParser.setDoNamespaces(true);

    // Parse the document

    theParser.parse(xmlInput);
    DOMDocument *theDOM = theParser.getDocument();
    theDOM->normalize();

    XercesDOMSupport theDOMSupport;
    XercesParserLiaison theParserLiaison;

    // Use the DOM to create a XercesDOMWrapperParsedSource,
    // which you can pass to the transform method.
    try
    {
        const XercesDOMWrapperParsedSource parsedSource(
                                   theDOM,
                                   theParserLiaison,
                                   theDOMSupport,

XalanDOMString(xmlInput.getSystemId()));

        xalan.transform(parsedSource, stylesheet, output);

    }
    catch (....)
    {
      ...
    }
}


XercesDOMWrapperParsedSource's first argument in its constructor is
'const DOM_Document &' (which is deprecated) whereas the
XercesDOMParser::getDocument() returns 'DOMDocument *'. Now obviously
you could just use the deprecated DOMParser instead of XercesDOMParser,
but is that dangerous? Why is it deprecated?

Thanks in advance for your help.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 22 April 2003 17:07
To: xalan-c-users@xml.apache.org
Subject: Re: problem with XSLT tranformation using Xalan






Please make sure you respond to the list, not to my personal address.

Since XalanDocument is an abstract base class, saying your "requirement
is to transform a document of type XalanDocument*" is not really
meaningful. If you have already parsed a document with the Xerces
parser, and you want to transform that, then following the link to the
usage pattern I pointed out, or look at the sample application I
mentioned.  Using the Xerces DOM for transformations, if there is no
need, is a waste of processing cycles, as it's not terribly efficient.

The XalanNode* constructor for XSLTInputSource will be deprecated and
disappear in future release -- that's the reason for the wrapper class.

Dave





                      Ashay

                      <[EMAIL PROTECTED]         To:
[EMAIL PROTECTED]

                      .com>                    cc:

                                               Subject: Re: problem with
XSLT tranformation using Xalan
                      04/22/2003 08:50

                      AM






Hi David,

I tried out the tranformation of an xml file the same way you've stated
below and it worked fine. But my requirement is to transform a document
of type XalanDocument* . An XSLTInputSource object can be created with a
XalanDocument object which can then be passed to the transform() method.
But this does not seem to be working and gives me the error that I
mentioned.

Any ideas what could be causing this error or what I might be missing in
my code.

[EMAIL PROTECTED] wrote:




 Unless you really need to use the Xerces DOM, you should avoid it.
Here's  a much simpler version without it:

 XalanTranformer::intialize();
 {
 XalanTransformer theTransformer;
 int theResult =
theTransformer.transform("foo.xml","foo.xsl","foo.out");
 cout << "theResult is: " << theResult ;
 }

 XalanTransformer::terminate();

 If you really need to use the Xerces DOM, see the ParsedSourceWrappers
sample, or this usage pattern:


http://xml.apache.org/xalan-c/usagepatterns.html#xercesdomwrapperparseds
ource


 Dave




 Ashay
 .com> cc: (bcc: David N Bertoni/Cambridge/IBM)
 Subject: problem with XSLT tranformation using Xalan  04/22/2003 04:32
AM




 Hi,

 I am very new to Xerces and Xalan.
 I am using Xerces 2.1.! 0 and Xalan 1.4.0.

 Based on one of the examples given on the Apache site, I wrote the
below  given simple code and got the following error message while
transforming a  XalanDocument.  I am getting -2 as a result of
XalanTransformer::tranform() method.

 Error msg:
 Fatal Error at (file , line 0, column 0): An exception occurred!
Type:RuntimeException, Message:The primary document entity could not be
opened. Id={null}  theResult = -2

 Could someone give me pointers as to why this error is caused. A speedy
reply would be highly appreciated.  Thanks in advance.

 The code:

************************************************************************
**
 // Use the Xerces DOM parser to create a DOM_Document.  #include
#include  DOMParser theParser;  // You MUST instruct the Xerces
DOMParser NOT to create a DOM_XMLDecNode  // in the DOM to represent the
XML declaration. See! "Limitations" below.
DOMParser::setToCreateXMLDeclTypeNode(false);
 theParser.parse("foo.xml");
 const DOM_Document theDOM = theParser.getDocument();
 // Set up a XercesParserLiaison and use it to wrap the DOM_Document  //
in a XalanDocument.  XercesDOMSupport theDOMSupport; XercesParserLiaison
theParserLiaison(theDOMSupport);
 XalanDocument* theDoc = theParserLiaison.createDocument(theDOM);
 // Use the XalanDocument to create an XSLTInputSource object, which  //
you can then use in a transformation.  XSLTInputSource
theInputSource(theDoc);  XSLTInputSource theXSLInput("foo.xsl");
XSLTResultTarget theOutput("foo.out");  XalanTranformer::intialize();
XalanTransformer theTransformer  int theResult =
theTransformer.transform(theInputSource,theXSLInput,theOutput);
 cout << "theresult is: " << theResult ;


************************************************************************
****




 Do you Yahoo!?
 The New Yahoo! Search - Faster. Easier. Bingo.




Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.






Reply via email to