Thanks for the info Dave. I will look into the memory stream, that's exactly what I'm looking for.
I do want to produce a tree-form on output as you described. I do not need to manipulate the tree but simply inspect the data in a meaningful way as opposed to parsing out a string. The Xalan form would be fine I'm sure. I'm assuming the method I described before will work (but do I still need the liaison?). I'll take a look at the example you described. getLastError did indeed return a -3 error as you described. I read the FAQ bit you linked and it made sense. Thanks for the help! -----Original Message----- From: David N Bertoni/Cambridge/IBM [mailto:[EMAIL PROTECTED] Sent: Thursday, January 23, 2003 5:10 PM To: '[email protected]' Subject: Re: General usage questions Hi Greg, First things first -- you should not use anything in Xerces for the inputs. You can use a memory stream as input to a transformation and a file for the stylesheet. It's not clear to me from your posting if that's the case, but can I assume it is? If not, take a look at the StreamTransform sample program. It will illustrate how to use anything that derives from std::istream for input. For the output, you can produce serialized XML in memory by using std::ostream. Take a look at the StreamTransform sample for that. You can then parse that XML, or process it in any other way you want. You can also produce the deprecated Xerces DOM on output, but not the new one. In the next release of Xalan, you will be able to produce the new Xerces DOM. This is probably what you want to do if you're going to manipulate the tree after you've transformed it, although I don't know what manipulations you could do in code that you can't do in your stylesheet. Lastly, you can produce Xalan's source tree on output, which is a DOM-like tree, but is not mutable. You might want to do this if you're going to do a two-stage transformation where the output of the first stage is the input to the second stage. For more information on producing the Xerces DOM or Xalan's source tree, look at the testXSLT program, which does either one, based on a command line switch. Now, the reason for the error -- this is not a XercesException, from what I can see, instead, it's a XalanDOMException. Can you please confirm that? If so, take a look at the error string returned from XalanTransformer::getLastError(). My guess is the error code will be 3, which is HIERARCHY_REQUEST_ERR. For more info, see the FAQ: http://xml.apache.org/xalan-c/faq.html#faq-14 Hope that helps. Dave "Dunko, Greg" <[EMAIL PROTECTED] To: "'[email protected]'" <[email protected]> COM> cc: (bcc: David N Bertoni/Cambridge/IBM) Subject: General usage questions 01/23/2003 12:34 PM Hiya folks. In the last couple days I've been trying to wrap my head around the Xalan/Xerces APIs and I've run into some trouble that I can't seem to get by. As background, I'm new to these APIs as the XML work I did a couple years ago was done using MSXML on Windows so I'm quite new to this library. I've tried looking at as much documentation and samples as I can but alas I have been unable to locate a clear direction for what I'm trying to do. The differences between the two libraries DOM models and the fact that the Xalan api uses the now deprecated Xerces DOM objects has me quite confused as to what I'm "supposed" to be doing to accomplish my task :) The basic issue is that I am trying to do some XSL transformations. My input is an XML string in memory, the stylesheet is in a file on disk, and I'd like my output to be in memory also (not in a file). I'd prefer DOM output instead of a string. It's not entirely clear to me on how to do this. My initial attempt was to use a std::stringstream object to construct an XSLTInputSource object but this didn't seem to work at all. Currently I have some code using the deprecated Xerces API to produce a DOM_Document. I'm then running that through the ParserLiasion and XercesDOMWrapperParsedSource objects to get it into the transform. This seems to work ok as long as the XSLTResultTarget points to a file on disk. My problem is that as soon as I try to make the output of the transformation use a XalanDocument it fails. I tried following what the documentation describes: XalanTransformer theXalanTransformer; XercesDOMSupport theDOMSupport; XercesParserLiaison theParserLiaison(theDOMSupport); // Produce input and stylesheet InputSources .... // XalanDocument* docOut = theParserLiaison.createDocument(); XSLTResultTarget theDOMResultTarget(docOut); int theResult = theXalanTransformer.transform(parsedSource, stylesheet , theDOMResultTarget); This seems to fail in the transform returning a -4. From inspecting the code this seems to be some sort of XercesException but there is no indication as to what the issue is. Remember that this works fine if theDOMResultTarget is constructed with a simple filename URI such as "output.xml". Just getting the DOM output doesn't seem to work for me. For a bit I thought the liaison could only be used once so I made a second one for making the XalanDocument but that didn't work either. Am I going about this whole thing the wrong way, making it more difficult than it needs to be? I would think this would be a fairly common task to perform and I'm a bit perplexed at the moment. Thanks for your help! -- Greg Dunko Fidelity Investments 603.791.8216 mailto:[EMAIL PROTECTED]
