Xalan using generic DOM structures..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ganesh Gella

    Xalan using generic DOM structures..

    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
  • Tjerk Wolterink

    #2
    Re: Xalan using generic DOM structures..

    Ganesh Gella wrote:
    [color=blue]
    > 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[/color]

    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.

    Comment

    • Ganesh Gella

      #3
      Re: Xalan using generic DOM structures..

      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,do msupport classes) as an input and gives the result in
      XSLTResultTarge t 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

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • Ganesh Gella

        #4
        Re: Xalan using generic DOM structures..

        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,do msupport classes) as an input and gives the result in
        XSLTResultTarge t 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

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Tjerk Wolterink

          #5
          Re: Xalan using generic DOM structures..

          Ganesh Gella wrote:[color=blue]
          > 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.[/color]

          I'm not excellent C++ programmer,
          but i know java well, and object oriented design principles,
          so i think i can help.
          [color=blue]
          >
          > Xalan accepts a xml file, a stream and a xerces dom object also (using
          > parserliason,do msupport classes) as an input and gives the result in
          > XSLTResultTarge t 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.[/color]

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

          Is that right?
          [color=blue]
          >
          > 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.[/color]

          Well, if you have your own Dom (Node, Element,Attribu te) 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.[color=blue]
          >
          > 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.[/color]


          Then *i think* you can transform it using Xalan XSLT processor.
          You get a Xerces dom in return.
          [color=blue]
          >
          > 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).[/color]

          I do not know much about events in xalan, so i cant help you there.
          [color=blue]
          >
          > Your inputs and ideas are highly appreciated in this regard.
          >
          > Thanks and Regards
          > Ganesh Gella
          >
          > *** Sent via Developersdex http://www.developersdex.com ***
          > Don't just participate in USENET...get rewarded for it![/color]

          Comment

          • David Bertoni

            #6
            Re: Xalan using generic DOM structures..

            Ganesh Gella wrote:
            [color=blue]
            > 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,do msupport classes) as an input and gives the result in
            > XSLTResultTarge t 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.
            >[/color]

            Take a look at how the Xerces-C DOM is wrapped by looking at the
            "wrapper" classes in the XercesParserLia ison 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.
            [color=blue]
            > 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).[/color]

            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
            XSLTResultTarge t. One of those things is a class called
            FormatterListen er, 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.
            [color=blue]
            >
            > Your inputs and ideas are highly appreciated in this regard.
            >[/color]

            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

            Comment

            • Ganesh Gella

              #7
              Re: Xalan using generic DOM structures..

              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
              FormatterToXerc esDOM) that implements FormatterListen er is the way to
              go.

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

              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

              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • Ganesh Gella

                #8
                Re: Xalan using generic DOM structures..

                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 XSLTResultTarge t
                class for this. This class accepts a FormatterToXerc esDOM class in its
                constructor. FormatterToXerc esDOM 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 FormatterListen er
                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 <tjerk@wolterin kwebdesign.com> wrote in message news:<4180b49a$ 0$62020$ee9da40 f@news.wanadoo. nl>...[color=blue]
                > Ganesh Gella wrote:[color=green]
                > > 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.[/color]
                >
                > I'm not excellent C++ programmer,
                > but i know java well, and object oriented design principles,
                > so i think i can help.
                >[color=green]
                > >
                > > Xalan accepts a xml file, a stream and a xerces dom object also (using
                > > parserliason,do msupport classes) as an input and gives the result in
                > > XSLTResultTarge t 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.[/color]
                >
                > Ok, so: you have your own Node classes?
                > Your own Element classes?
                >
                > Is that right?
                >[color=green]
                > >
                > > 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.[/color]
                >
                > Well, if you have your own Dom (Node, Element,Attribu te) 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.[color=green]
                > >
                > > 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.[/color]
                >
                >
                > Then *i think* you can transform it using Xalan XSLT processor.
                > You get a Xerces dom in return.
                >[color=green]
                > >
                > > 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).[/color]
                >
                > I do not know much about events in xalan, so i cant help you there.
                >[color=green]
                > >
                > > Your inputs and ideas are highly appreciated in this regard.
                > >
                > > Thanks and Regards
                > > Ganesh Gella
                > >
                > > *** Sent via Developersdex http://www.developersdex.com ***
                > > Don't just participate in USENET...get rewarded for it![/color][/color]

                Comment

                Working...