RE: [xsl] Problem with simple xsl:when test expression

Subject: RE: [xsl] Problem with simple xsl:when test expression
From: Rene de Vries <RdVries@xxxxxxxxxxx>
Date: Wed, 4 Jul 2001 09:22:34 +0200
Hi Phil,

As far as I can see there's nothing wrong with it, but are you using the 
xsl:when in the right template? You can also check if the template is used 
at all, by letting the xsl:otherwise generating some text. If no text 
appears, your template isn't used at all.
If you still have problems, you have to show us more of your xsl.

<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:fo="http://www.w3.org/1999/XSL/Format";>

	<xsl:template match="root">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="simpleType">
		<xsl:choose>
			<xsl:when test="./restriction[@base='string']">
				@base is 'string'
			</xsl:when>
			<xsl:otherwise>
				@base is not 'string'
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
</xsl:stylesheet>

worked fine with me!

Greetings Rene
   { @   @ }
        ^
      \__/

"You don't need eyes to see, you need vision!"

-----Oorspronkelijk bericht-----
Van:	Phil Mitchell [SMTP:philip_mitchell@xxxxxxxxxxx]
Verzonden:	woensdag 4 juli 2001 8:34
Aan:	XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Onderwerp:	[xsl] Problem with simple xsl:when test expression

I am trying to write a test expression for a when clause that will be true
when the context node has a child 'restriction' element whose 'base'
attribute is "string" -- i.e. <restriction base="string">. I think this
clause should simply be:

         <xsl:choose>
	  <xsl:when test="./restriction[@base='string']">
	  </xsl:when>
         </xsl:choose>

But it doesn't seem to work -- it doesn't match. What is wrong with this?
Here is the context node:

<simpleType name="MedlarsNameString">
   </annotation>
   <restriction base="string">
   </restriction>
</simpleType>

And here is the stylesheet fragment (slightly edited -- yes, the second
choose block is meant to be nested in an otherwise block.):

<xsl:template match="xsd:simpleType">
   <xsl:param name="elementName"/>
    <xsl:choose>
       <xsl:when test="@name='TextBlock'">
        Do this....
       </xsl:when>
       <xsl:otherwise>
         <xsl:choose>
	  <xsl:when test="./restriction[@base='string']">
	  Print here.
            </xsl:when>
         </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>
</xsl:template>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread