Subject: Re: [xsl] testing for a missing attribute From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 10 Jul 2010 22:34:52 -0400 |
I'm trying to process an XML schema and produce some documentation. I'm trying to trap the various ways min/max occurs can be specified and give the typical option/required/repeating translation. min/maxOccurs are not required values and they default to 1 when not specified. I'm having troubles detecting this situation.
Here is what I've been trying, but it isn't working unless values are specified:
<xsl:choose> <xsl:when test="@minOccurs=0 and @maxOccurs=''"> optional
</xsl:when>
<xsl:when test="@minOccurs=nil and @maxOccurs=nil"> required
</xsl:when>
<xsl:when test="@minOccurs=1 and @maxOccurs=1"> required
</xsl:when>
<xsl:when test="@minOccurs=1 and @maxOccurs='unbounded'"> required repeating
</xsl:when>
<xsl:when test="@minOccurs='' and @maxOccurs='unbounded'"> required repeating
</xsl:when>
<xsl:otherwise> min:<xsl:value-of select="@minOccurs"/> max:<xsl:value-of select="@maxOccurs"/>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="minOccurs" select="(@minOccurs,1)[1]"/> <xsl:variable name="maxOccurs" select="(@maxOccurs,1)[1]"/>
-- XSLT/XQuery training: after http://XMLPrague.cz 2011-03-28/04-01 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] testing for a missing attribu, Dan Vint | Thread | Re: [xsl] testing for a missing att, Dan Vint |
[xsl] testing for a missing attribu, Dan Vint | Date | Re: [xsl] testing for a missing att, Dan Vint |
Month |