This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: create new elements as output



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]