Xalan using generic DOM structures..

G

Ganesh Gella

Hi All,

I am planning to use Xalan to transform XML data by applying xls
stylesheets.

Here tricky part is, Xalan provides several C++ APIs, which are very
much useful if our requirement is just inputting a file and getting a
file. Or giving a xerces dom and get a new xerces dom.

I would like to know whether any of you tried with their own custom
made DOM structures and used Xalan to transform them ?

I would like to know, is there any way, by which one of the methods
like transform throw SAX events by which we can build our DOM
structures ? And in the same way input also using SAX events. (insteas
of taking certain formatted DOMs and returning fixed DOM structures).

If any of you tried Xalan for such requirements, I request you to
throw some pointers on this topic. I appreciate your help in this
regards.

Thanks
Ganesh
 
T

Tjerk Wolterink

Ganesh said:
Hi All,

I am planning to use Xalan to transform XML data by applying xls
stylesheets.

Here tricky part is, Xalan provides several C++ APIs, which are very
much useful if our requirement is just inputting a file and getting a
file. Or giving a xerces dom and get a new xerces dom.

I would like to know whether any of you tried with their own custom
made DOM structures and used Xalan to transform them ?

I would like to know, is there any way, by which one of the methods
like transform throw SAX events by which we can build our DOM
structures ? And in the same way input also using SAX events. (insteas
of taking certain formatted DOMs and returning fixed DOM structures).

If any of you tried Xalan for such requirements, I request you to
throw some pointers on this topic. I appreciate your help in this
regards.

Thanks
Ganesh

I do not really understand your question.

You want XML to be transformed with an XSL to an other XML format?
is that right?

Xalan can do the transformation process for you,
i do not see what the problem is.

I think you mean, you want to have some control over the transformation
process, am i right?

Give an example please.
 
G

Ganesh Gella

Hi,

Thanks for your reply.
Let me try to explain the problem in some detail now.

Yes, my intention is to xonvert one XML document to another using XLS.
And Xalan has some C++ APIs for it.

Xalan accepts a xml file, a stream and a xerces dom object also (using
parserliason,domsupport classes) as an input and gives the result in
XSLTResultTarget class.

Here my problem is, our code is already having it's own DOM object
(different from xerces DOM) which is constructed based on SAX events.

I wanted to know how to plug-in this DOM object to Xalan's transform
methods so that I can use it's transform capabilities.

It has built-in methods to transform, xerces doms, I wanted to know is
there any way we can plug in our own DOM objects and get the output in
may be xerces dom or in the same format that we need.

Or in other words, my question can be phrased like this,

Do xalan transform methods always require a already built-in DOM objects
? Can transform methods accept SAX events ? such that it itself creates
the dom and throws us resultant sax events ? (Once it throws the sax
events, we can build our own DOM (like xerces DOM).

Your inputs and ideas are highly appreciated in this regard.

Thanks and Regards
Ganesh Gella
 
G

Ganesh Gella

Hi,

Thanks for your reply.
Let me try to explain the problem in some detail now.

Yes, my intention is to xonvert one XML document to another using XLS.
And Xalan has some C++ APIs for it.

Xalan accepts a xml file, a stream and a xerces dom object also (using
parserliason,domsupport classes) as an input and gives the result in
XSLTResultTarget class.

Here my problem is, our code is already having it's own DOM object
(different from xerces DOM) which is constructed based on SAX events.

I wanted to know how to plug-in this DOM object to Xalan's transform
methods so that I can use it's transform capabilities.

It has built-in methods to transform, xerces doms, I wanted to know is
there any way we can plug in our own DOM objects and get the output in
may be xerces dom or in the same format that we need.

Or in other words, my question can be phrased like this,

Do xalan transform methods always require a already built-in DOM objects
? Can transform methods accept SAX events ? such that it itself creates
the dom and throws us resultant sax events ? (Once it throws the sax
events, we can build our own DOM (like xerces DOM).

Your inputs and ideas are highly appreciated in this regard.

Thanks and Regards
Ganesh Gella
 
T

Tjerk Wolterink

Ganesh said:
Hi,

Thanks for your reply.
Let me try to explain the problem in some detail now.

Yes, my intention is to xonvert one XML document to another using XLS.
And Xalan has some C++ APIs for it.

I'm not excellent C++ programmer,
but i know java well, and object oriented design principles,
so i think i can help.
Xalan accepts a xml file, a stream and a xerces dom object also (using
parserliason,domsupport classes) as an input and gives the result in
XSLTResultTarget class.

Here my problem is, our code is already having it's own DOM object
(different from xerces DOM) which is constructed based on SAX events.

Ok, so: you have your own Node classes?
Your own Element classes?

Is that right?
I wanted to know how to plug-in this DOM object to Xalan's transform
methods so that I can use it's transform capabilities.

Well, if you have your own Dom (Node, Element,Attribute) classes
then that is impossible *i think*.

Unless:

first, why do you have your own Dom classes?
Probably to give some extended functionality.

But if you want to give Dom classes extended functionality,
you should subclass the XalanNode classes [ XalanElement etc]
wich you want to have more functionality.
It has built-in methods to transform, xerces doms, I wanted to know is
there any way we can plug in our own DOM objects and get the output in
may be xerces dom or in the same format that we need.


Then *i think* you can transform it using Xalan XSLT processor.
You get a Xerces dom in return.
Or in other words, my question can be phrased like this,

Do xalan transform methods always require a already built-in DOM objects
? Can transform methods accept SAX events ? such that it itself creates
the dom and throws us resultant sax events ? (Once it throws the sax
events, we can build our own DOM (like xerces DOM).

I do not know much about events in xalan, so i cant help you there.
 
D

David Bertoni

Ganesh said:
Hi,

Thanks for your reply.
Let me try to explain the problem in some detail now.

Yes, my intention is to xonvert one XML document to another using XLS.
And Xalan has some C++ APIs for it.

Xalan accepts a xml file, a stream and a xerces dom object also (using
parserliason,domsupport classes) as an input and gives the result in
XSLTResultTarget class.

Here my problem is, our code is already having it's own DOM object
(different from xerces DOM) which is constructed based on SAX events.

I wanted to know how to plug-in this DOM object to Xalan's transform
methods so that I can use it's transform capabilities.

Take a look at how the Xerces-C DOM is wrapped by looking at the
"wrapper" classes in the XercesParserLiaison source directory. However,
it's not a trivial undertaking, that's for sure. If your "DOM" is close
to a standard DOM, you can probably do a "cut-and-paste" approach, and
have your wrapper working pretty quickly.
It has built-in methods to transform, xerces doms, I wanted to know is
there any way we can plug in our own DOM objects and get the output in
may be xerces dom or in the same format that we need.

Or in other words, my question can be phrased like this,

Do xalan transform methods always require a already built-in DOM objects
? Can transform methods accept SAX events ? such that it itself creates
the dom and throws us resultant sax events ? (Once it throws the sax
events, we can build our own DOM (like xerces DOM).

Xalan-C will either use its default source tree implementation, which
you can build by parsing a source file with the parser, or through
sending your own SAX2 events. See the DocumentBuilder sample for more
information on how you can do that. Xalan-C always works best with its
default source tree implementation, which is optimized for XSLT.
Xalan-C always builds the entire tree into memory.

As for output, take a look at what you can provide to the constructor of
XSLTResultTarget. One of those things is a class called
FormatterListener, which is like a SAX DocumentHandler. If you want the
output as events, you can create your own derivative of that, and do
what you want with the events.
Your inputs and ideas are highly appreciated in this regard.

You should consider joining one of the Xalan-C mailing list and posting
your questions there. You will get far faster and more detailed replies
there.

Dave
 
G

Ganesh Gella

Hi Dave,

Thanks for your reply. On the output side it is some what clear to me on
how to move ahead.
As you said, creating a new calss(in similare lines of
FormatterToXercesDOM) that implements FormatterListener is the way to
go.

Then my new class can be given to the constructor of XSLTResultTarget.

I will try to implement this and see how far I can get through.

On the input side, I am still having doubts on how I can pump the events
to xalan and ask it to do the transform from there on..

Let me first start with creating FormatterLister like class and then get
back to you with further questions.

Thanks
Ganesh
 
G

Ganesh Gella

Hi All,

I started exploring on the output side and creating my own DOM
structure using Xalan's transform method.

As discussed in the group before, I am depending on XSLTResultTarget
class for this. This class accepts a FormatterToXercesDOM class in its
constructor. FormatterToXercesDOM is derived from an abstract class
FormatterLister, which is a class derived from DocumentHandler.

So here I created a new class that is derived from FormatterListener
and passes on the events to another clas that is derived from
ContentHandler. (The existing parser in my code is derived from
ContentHandler).

Here I came across following problem,

all parsers that derive from DocumentHandler are using AttributeList
objects and all those who derive from ContentHandler are using
Attributes class. The major difference is, Attributes does not have
URI,QName explicitely.

Now I need to bridge AttributeList class to Attributes class. I would
like to know whether any of you worked on a similar problem before and
have some clues on converting attributelist class to attributes ?

Any pointers and help is highly appreciated.

Thanks
Ganesh

Tjerk Wolterink said:
Ganesh said:
Hi,

Thanks for your reply.
Let me try to explain the problem in some detail now.

Yes, my intention is to xonvert one XML document to another using XLS.
And Xalan has some C++ APIs for it.

I'm not excellent C++ programmer,
but i know java well, and object oriented design principles,
so i think i can help.
Xalan accepts a xml file, a stream and a xerces dom object also (using
parserliason,domsupport classes) as an input and gives the result in
XSLTResultTarget class.

Here my problem is, our code is already having it's own DOM object
(different from xerces DOM) which is constructed based on SAX events.

Ok, so: you have your own Node classes?
Your own Element classes?

Is that right?
I wanted to know how to plug-in this DOM object to Xalan's transform
methods so that I can use it's transform capabilities.

Well, if you have your own Dom (Node, Element,Attribute) classes
then that is impossible *i think*.

Unless:

first, why do you have your own Dom classes?
Probably to give some extended functionality.

But if you want to give Dom classes extended functionality,
you should subclass the XalanNode classes [ XalanElement etc]
wich you want to have more functionality.
It has built-in methods to transform, xerces doms, I wanted to know is
there any way we can plug in our own DOM objects and get the output in
may be xerces dom or in the same format that we need.


Then *i think* you can transform it using Xalan XSLT processor.
You get a Xerces dom in return.
Or in other words, my question can be phrased like this,

Do xalan transform methods always require a already built-in DOM objects
? Can transform methods accept SAX events ? such that it itself creates
the dom and throws us resultant sax events ? (Once it throws the sax
events, we can build our own DOM (like xerces DOM).

I do not know much about events in xalan, so i cant help you there.
Your inputs and ideas are highly appreciated in this regard.

Thanks and Regards
Ganesh Gella
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top