You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Marco Antonio Dias Campelo <mc...@timbrasil.com.br> on 2004/07/13 17:49:16 UTC

Problem with template match

Hello,

I built some xsl files using the XML Spy tool. The problem is that the behavior in XML Spy is different of the behavior when I transform my XML using XalanJ (WebLogic 8.1).

XML to be transformed:

<BLAH_ADP_OUT_PARAMETERS>
	<RECORD name="OCC" index="0">
		<PARAM name="CO_ID" value="12345"/>
	</RECORD>
</BLAH_ADP_OUT_PARAMETERS>

Block of the occ.xsl:

<xsl:template match="RECORD[@name='OCC']" mode="occ">
	<occ>
	    <xsl:attribute name="index"><xsl:value-of select="@index"></xsl:value-of></xsl:attribute>
	    <xsl:apply-templates mode="contract" select="."></xsl:apply-templates>
	</occ>
</xsl:template>

Block of the contract.xsl:

<xsl:template name="contract"  match="."  mode="contract">
		<contract>
		     <xsl:apply-templates mode="contract-data"></xsl:apply-templates>
		</contract>
</xsl:template>

When I transform using XML Spy, everything runs OK. When I transform under Weblogic (XalanJ) or Jbuilder I got the error message below:

Error:

A node test that matches either NCName:* or QName was expected.;

I found that the problem is:

<xsl:template name="contract"  match="."  mode="contract">

I can not use match=".". Instead of ., I have to use match="RECORD[@name='OCC']".

I did a lot of search by Internet and somebody said that match="." is not valid.

What about select="."? It seems to work fine.

I do not want to use match="RECORD[@name='OCC'] because the tag <PARAM name=CO_ID> can appear under different nodes:

<RECORD name="OCC" index="0">
	<PARAM name="CO_ID" value="12345"/>
</RECORD>

or

<RECORD name="BLAH" index="0">
	<PARAM name="CO_ID" value="12345"/>
</RECORD>

What is a good solution? I want to have only 1 contract.xsl working under different situations. That's why I used match=".".

Thanks in advance,
Marco CampĂȘlo