Reading XSLT from Java

Discussion in 'XML' started by cybernerdsx2, Dec 13, 2005.

  1. cybernerdsx2

    cybernerdsx2 Guest

    Hi,

    I am new to XSLT and I would like to use Java to read up the XSLT
    content and add in a few tags in into the template below:

    <xsl:template name="hwSpecs">
    <!-- adding new tags into here from Java -->
    </xsl:template>

    So, what kind of parser or tools can I use in my Java source code to
    deal with this?

    Many thanks.

    Mike
     
    cybernerdsx2, Dec 13, 2005
    #1
    1. Advertising

  2. cybernerdsx2 wrote:
    > I am new to XSLT and I would like to use Java to read up the XSLT
    > content and add in a few tags in into the template below:
    >
    > <xsl:template name="hwSpecs">
    > <!-- adding new tags into here from Java -->
    > </xsl:template>
    >
    > So, what kind of parser or tools can I use in my Java source code to
    > deal with this?


    XSLT is XML-based, so you can use e.g. an XML DOM parser to do that.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Dec 13, 2005
    #2
    1. Advertising

  3. cybernerdsx2

    cybernerdsx2 Guest

    Thanks. Can I use JDOM for doing that?
    Any simple example to, say, read the tag <xsl:template name="hwSpecs"> ?
     
    cybernerdsx2, Dec 13, 2005
    #3
  4. cybernerdsx2 wrote:

    > Thanks. Can I use JDOM for doing that?


    I think you can.

    > Any simple example to, say, read the tag <xsl:template name="hwSpecs"> ?


    I don't use JDOM. But there should be a method to read all template
    elements from XSLT 1.0 namespace. Then get the element with the specific
    name attribute value.
    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Dec 13, 2005
    #4
  5. cybernerdsx2 wrote:


    > I am new to XSLT and I would like to use Java to read up the XSLT
    > content and add in a few tags in into the template below:
    >
    > <xsl:template name="hwSpecs">
    > <!-- adding new tags into here from Java -->
    > </xsl:template>
    >
    > So, what kind of parser or tools can I use in my Java source code to
    > deal with this?


    Java 1.4 and later has XSLT 1.0 support so one way to do that is to
    write an XSLT 1.0 stylesheet that processes an input stylesheet and
    generates a new output stylesheet. After all, XSLT is XML so you can use
    XSLT itself to process and to generate XSLT.

    Or you could write a Java program using the W3C DOM to parse the input
    stylesheet into a DOM tree and then use the DOM API to add elements.
    Then you need to serialize to DOM tree to get a new XML document file.

    Besides those tools built-in for Java 1.4 or 1.5 you can of course have
    a look at the various third party implementations for XSLT, DOM.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Dec 13, 2005
    #5
  6. cybernerdsx2

    Sreeni Guest

    In Java, for XSLT, You can do all the things that you can do in XML
    "cybernerdsx2" <> wrote in message
    news:...
    > Thanks. Can I use JDOM for doing that?
    > Any simple example to, say, read the tag <xsl:template name="hwSpecs"> ?
    >
     
    Sreeni, Dec 14, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    687
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,691
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    625
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    724
    Henry S. Thompson
    Oct 19, 2005
  5. Replies:
    4
    Views:
    683
Loading...

Share This Page