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 David Bertoni <db...@apache.org> on 2006/06/01 20:13:58 UTC
Re: Xalan transform hand-built DOM
Peter.Marron@trilliumsoftware.com wrote:
>
> Hi,
>
> I'm using Xalan version 1.9 and Xerces version 2.6 in C++
> on windows. I'm having a problem using XalanTransformer.
>
> I am building up a DOM by hand.
> I have defined my own classes that derive from XalanNode
> and XalanDocument and so on.
> I've tried this approach to using XPathEvaluator.evaluate
> and it worked fine.
>
> Now I am trying the same thing with XalanTransformer.transform
> I assumed that because there is a constructor for
> XSLTInputSource that takes a XalanNode* then I could use that.
> In effect I have code like this
>
> XalanNode *node;
> // Stuff to set up the input DOM in node
> XSLTInputSource input(node);
> transformer.transform(input, stylesheet, output);
>
> (Where I've glossed over the setting up the XSLTInputSource
> for the stylesheet the XSLTResultTarget for the output and the
> XalanTransformer itself.)
>
> When I try this I get an error:
>
> SAXParseException: An exception occurred! Type:RuntimeException,
> Message:The
> primary document entity could not be opened. Id={null} (, line 0, column 0)
>
> The fact that this is a SAX parse exception makes me think
> that the transformer is going off and try to parse my DOM object!
> Also when I try to follow the flow through the debugger it
> seems to be going off to do a parse.
> This all suggests that I am doing something rather fundamentally wrong.
>
> What approach should I be taking to transform a DOM I've built by hand?
>
Well, it's a code path that certainly hasn't been well-tested for quite
a while. Can you create Jira issue, and attach the source code for a
trivial program that reproduces the problem?
Thanks,
Dave
Re: Xalan transform hand-built DOM
Posted by David Bertoni <db...@apache.org>.
Peter.Marron@trilliumsoftware.com wrote:
>
> Hi,
>
> Thank you for your reply.
>
> I am having difficulty "creating a Jira" issue.
> I assume that to do this I need to be able to access
> "http://nagoya.apache.org/jira"
> and I have not been able to do this all day.
Jira is really very unstable, so I'm not surprised.
>
> I have, as suggested, created a trivial program that illustrates the
> problem.
> It is based on the XalanTransfrom example with minimal changes.
> It is attached.
>
> Hopefully it shows where I am going wrong.
> Maybe the problem is with my approach rather than any bug in Xalan.
OK, the bad news is this is really something we haven't supported in a
very long time. In fact, I'm not sure if XalanTransformer ever
supported using a pre-built tree in this way. We should probably remove
the XalanNode constructor from XSLTInputSource.
The good news is the way you can do this is fairly straightforward. You
need to create your own derivative of XalanParsedSource, and wrap your
document instance in that. You really need to do a bit more work to get
your own XalanDocument implementation to work anyway.
To get your own custom implementation of XalanDOM to work you need to
provide a derivative of the DOMSupport class that understands your
implementation. You can probably just use DOMSupportDefault, but you
should create your own if you can optimize node-ordering for your
implementation. For example, XalanSourceTree (the default
implementation) uses indexing to support fast node ordering. I would
highly recommend you do something like that, if you want to see
reasonable performance.
Once you've done that, you can create a XalanParsedSource derivative
that wraps your XalanDocument instance. That's trivial, and you can
look at the existing code in the XalanTransformer directory for ideas.
Of course, you can always use XercesDOMWrapperParsedSource with an
instance of the Xerces-C DOM that you've built by hand, and forget about
creating your own XalanDOM. In addition, if you can build your DOM
instance in document order, you can use Xalan's default XalanDOM
implementation, and just build it using hand-made SAX events. Take a
look at the DocumentBuilder sample for more information.
Feel free to post again if this isn't clear, or you have more questions.
Dave
Re: Xalan transform hand-built DOM
Posted by Pe...@trilliumsoftware.com.
Hi,
Thank you for your reply.
I am having difficulty "creating a Jira" issue.
I assume that to do this I need to be able to access
"http://nagoya.apache.org/jira"
and I have not been able to do this all day.
I have, as suggested, created a trivial program that illustrates the
problem.
It is based on the XalanTransfrom example with minimal changes.
It is attached.
Hopefully it shows where I am going wrong.
Maybe the problem is with my approach rather than any bug in Xalan.
In the short term I would be happy to adopt any approach which allows
me to transform a DOM that I have built without a parser.
(All of the examples that transform DOMs
seem to assume that you have obtained the DOM from a parser.)
I had assumed that the XSLTInputSource class would
allow me to do that, but in the short term if there is
any way that works then I would be most grateful to know what it is.
Many thanks in advance.
Peter Marron
David Bertoni <db...@apache.org>
01/06/2006 19:13
Please respond to
xalan-c-users@xml.apache.org
To
xalan-c-users@xml.apache.org
cc
Subject
Re: Xalan transform hand-built DOM
Peter.Marron@trilliumsoftware.com wrote:
>
> Hi,
>
> I'm using Xalan version 1.9 and Xerces version 2.6 in C++
> on windows. I'm having a problem using XalanTransformer.
>
[snip]
>
> What approach should I be taking to transform a DOM I've built by hand?
>
Well, it's a code path that certainly hasn't been well-tested for quite
a while. Can you create Jira issue, and attach the source code for a
trivial program that reproduces the problem?
Thanks,
Dave