This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: create new elements as output
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] create new elements as output
- From: "Kevin Jones" <kjouk at yahoo dot co dot uk>
- Date: Wed, 28 Mar 2001 11:47:18 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
>
>Hi. I appreciate any help that anyone would like to offer. Thanks.
>Problem: Using XSL in trying to transform XML file into another XML file
>with differing element names and adding a group element. Use of "name" for
>creating elements is ignored, and don't understand why.
>
There are a few problems with the stylesheet that you sent in.
The namespace should have been
"xmlns:xsl="http://www.w3.org/1999/XSL/Transform". This has been commented
out in out version. The other namespace is for a Microsoft only version of
XSL, see http://www.netcrucible.com/xslt/msxml-faq.htm for a description of
the difference.
The stylesheet element also needed a version="1.0" attribute to make it
valid.
The FareRules template was closing the 'Text' element before processing the
other templates.
This should do what you need.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="FareRules">
<xsl:element name="Text">
<xsl:apply-templates select="PenRules"/>
<xsl:apply-templates select="MinStay"/>
<xsl:apply-templates select="MaxStay"/>
</xsl:element>
</xsl:template>
<xsl:template match="PenRules">
<xsl:element name="PenaltyRules">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="MinStay">
<xsl:element name="MinimumStay">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
<xsl:template match="MaxStay">
<xsl:element name="MaximumStay">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Regards,
Kev.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list