How to print a whole XML-tree with XSLT?

Discussion in 'XML' started by meyer.dominik@googlemail.com, Oct 3, 2005.

  1. Guest

    Hi there!
    I'm a newbie in XSLT, so maybe this problem is easy to solve, but I
    just don't get it and hours of searching for an answer didn't help me
    either.

    Is there any possibility to print a whole XML-tree, including all
    (child)elements and attributes, from a XML to a (X)HTML-file using
    xsl(t)?

    I got a dynamic XML like this:

    -- xml --

    <configSet>
    <xmlSet id="0">
    <!-- Dynamic content -->
    </xmlSet>

    <xmlSet id="1">
    <!-- Dynamic content -->
    </xmlSet>

    <xmlSet id="2">
    <!-- Dynamic content -->
    </xmlSet>
    </configSet>

    -- end of xml --


    The xmlSet-Elements can contain various elements, which names and
    attributes I don't know (since they're created dynamically). I even
    don't know how deep they're nested.

    What I'd like to get is a HTML like this:

    -- html --

    <html>
    <body>
    <h1>Content of id 0</h1>

    <!-- The whole content of the xmlSet-element with the id "0" including
    all children and their attributes go here -->

    <h1>Content of id 1</h1>

    <!-- The whole content of the xmlSet-element with the id "1" including
    all children and their attributes go here -->

    ....

    </body>
    </html>

    -- end of html --


    Can you guys help me? Thanks in advance!
    , Oct 3, 2005
    #1
    1. Advertising

  2. wrote:


    > Is there any possibility to print a whole XML-tree, including all
    > (child)elements and attributes, from a XML to a (X)HTML-file using
    > xsl(t)?


    Programmatically you can certainly copy any stuff from the input XML to
    the XSLT output (e.g. with <xsl:copy-of select="xmlSet" />) but I don't
    see what sense it would make to have the XML elements then in a HTML
    document. What should the browser do with XML in a HTML document when it
    renders the HTML? It will parse the whole document with its HTML tag
    soup parser and treat that XML as unknown HTML stuff and render any text
    nodes probably. Is that what you want?



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 3, 2005
    #2
    1. Advertising

  3. Guest

    Thanks a lot for your answer! Now i know where my problem is. What i
    didn't regard is the fact that the browser won't show me the elements
    he doesn't know, since they're not text for them.
    In fact, what i want is an output like this:

    --- browser output --

    Content of id 1:

    <xmlSet id="1">

    <!-- Dynamic content starts here -->

    <otherNode>
    <andAnotherOne />
    </otherNode>

    <!-- Dynamic content starts here -->

    </xmlSet>

    ....

    -- end of browser output --

    So my elements have to be transformed into text. Do you see any
    possibility there?
    , Oct 3, 2005
    #3
  4. Guest

    Thanks a lot for your answer! Now i know where my problem is. What i
    didn't regard is the fact that the browser won't show me the elements
    he doesn't know, since they're not text for them.
    In fact, what i want is an output like this:

    --- browser output --

    Content of id 1:

    <xmlSet id="1">

    <!-- Dynamic content starts here -->

    <otherNode>
    <andAnotherOne />
    </otherNode>

    <!-- Dynamic content starts here -->

    </xmlSet>

    ....

    -- end of browser output --

    So my elements have to be transformed into text. Do you see any
    possibility there?


    ---
    EDIT:

    I finally found a solution: I just surrounded the output of the
    xmlSet-Elements by "textarea"-tags!

    Thanks again, Martin!
    , Oct 3, 2005
    #4
    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. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,110
  2. \A_Michigan_User\
    Replies:
    2
    Views:
    887
    \A_Michigan_User\
    Aug 21, 2006
  3. keto
    Replies:
    0
    Views:
    930
  4. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    348
    David Cournapeau
    Dec 30, 2008
  5. Kirill Shutemov

    whole CVS tree

    Kirill Shutemov, Oct 26, 2006, in forum: Ruby
    Replies:
    0
    Views:
    85
    Kirill Shutemov
    Oct 26, 2006
Loading...

Share This Page