How to print a whole XML-tree with XSLT?

M

meyer.dominik

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!
 
M

Martin Honnen

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?
 
M

meyer.dominik

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?
 
M

meyer.dominik

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!
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top