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]
Other format: [Raw text]

call-templates


Hello again,

I seem to have one problem more.

I thought that I understood <xsl:call-template ..> but it seems not to be 
the case.

I am given the job of transforming an XML document to another XML document. 
In the original document, the values contained in the nodes depend on the 
type attribute. The output XML document should have nodes which name tells 
something about the values.

Testing my solution on IE. 6.0 I get the following error:
Keyword xsl:call-templates may not be used here.

I am totally blank - none of the examples I have found gives me any reason 
for the behavior.

Sincerly
Ragulf Pickaxe :)

XML fragment:

<root>
  <DataList>
    <Data Type="101"><Node1>Value1</Node1><Node2></Node2></Data>
    <Data Type="102"><Node1>Value1</Node1><Node2>Value2</Node2></Data>
    <Data Type="103"><Node1>Value1</Node1><Node2></Node2></Data>
    <Data Type="201"><Node1>Value1</Node1><Node2>Value3</Node2></Data>
    <Data Type="202"><Node1>Value1</Node1><Node2>Value3</Node2></Data>
  </DataList>
</root>

XSL fragment:

<xsl:template match="DataList">
  <xsl:choose>
    <xsl:when test="@Type='101' or @Type='102' or @Type='103'">
  <!-- Not having implemented the solution to my last question. -->
      <xsl:call-templates name="Do-Something"/>
    </xsl:when>
    <xsl:when test="@Type='201' or @Type='202' or @Type='203'">
      <xsl:call-templates name="Do-Something-Else"/>
    </xsl:when>
    <xsl:otherwise></xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="Do-Something">
  <This><xsl:value-of select="Node1"/></This>
  <xsl:if test="Type='102'">
    <That><xsl:value-of select="Node2"/></That>
  </xsl:if>
</xsl:template>

<xsl:template name="Do-Something-Else">
  <This><xsl:value-of select="Node1"/></This>
  <AnotherThat><xsl:value-of select="Node2"/></AnotherThat>
</xsl:template>


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


 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]