waiting with transforming some XML

Michael Birkmose

Usenet Archive
Joined
Jul 22, 2003
Messages
6
Reaction score
0
Hi everyone!

I am new to XSL and I was wondering if the following is possible:

XML

<document title="Hello World">
<menu>
<menuitem>Test</menuitem>
</menu>
<Some_tags....>
</document>

This should be transformed to (using XSL):

HTML
<html>
<head>
<title>Hello World</title>
<body>
<Transformation of the some_tags element>
<Transformation of the menu element and its subelements> </body> </head> </html>

What I want to do is to transform the <some_tags> element before the <menu>. Moving the <menu> and the <some_tags> element around ind the xml is not an option :)

Best regards,
Michael
 

Andy Fish

Usenet Archive
Joined
Dec 30, 2002
Messages
605
Reaction score
0
yes, the answer is it's easy and it's just the sort of thing XSL is meant for. This is completely untested but your stylesheet will look something like:

<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="document/@title"/></title> <body> <xsl:apply-templates select="document/some-tags".> <xsl:apply-templates select="document/menu".> </body> </head> </html> </xsl:template>

<xsl:template match="some-tags">
..
</xsl:template>

<xsl:template match="menu">
...
</xsl:template>

Andy

"Michael Birkmose" <michael at gisp dot dk> wrote:

Hi everyone!

I am new to XSL and I was wondering if the following is possible:

XML

<document title="Hello World">
<menu>
<menuitem>Test</menuitem>
</menu>
<Some_tags....>
...
<menu>.
Moving the <menu> and the <some_tags> element around ind the xml is not an option :)

Best regards,
Michael
 

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
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top