Re: [xsl] strong typed variable with restriction ?

Subject: Re: [xsl] strong typed variable with restriction ?
From: Matthieu Ricaud-Dussarget <matthieu.ricaud@xxxxxxxxx>
Date: Wed, 02 Feb 2011 12:23:37 +0100
Hi Martin,

I use Saxon9 HE.

But I have to say the code I sent in this mail is a simplified version of the real one.
I thought it is the same problem but after what you say, I have to test this more.


This is actually a variable within the function which is typed as element() (not the function itself)

This is my real function (see the FIXME) :

<xsl:function name="igs:get-css-rule" as="element()*">
<xsl:param name="e" as="element()"/>
<xsl:param name="csspath" as="xs:string"/>
<xsl:param name="mode" as="xs:string"/><!--(override|not-override)-->
<xsl:param name="css" as="xs:string"/><!--(csstidy|css)-->
<xsl:variable name="class" select="string($e/@class)" as="xs:string"/>
<xsl:variable name="css" as="element()">
<!--FIXME : would works with element()* here -->
<xsl:choose>
<xsl:when test="$css='csstidy'">
<xsl:sequence select="igs:get-css-tidy($csspath,$mode)"/>
</xsl:when>
<xsl:when test="$css='css'">
<xsl:sequence select="igs:get-css($csspath)"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="$e/@class='nt' and $e='Attention'">
<xsl:message>css=<xsl:copy-of select="$css"/></xsl:message>
</xsl:if>
<xsl:choose>
<xsl:when test="$mode='both'">
<xsl:sequence select="igs:get-css-rule($e,$csspath,'override',$css)"/>
<xsl:sequence select="igs:get-css-rule($e,$csspath,'not-override',$css)"/>
</xsl:when>
<xsl:when test="$mode='override'">
<xsl:variable name="classOver" select="igs:get-class-over($e)" as="xs:string"/>
<xsl:variable name="selector" select="concat(if (name($e)='p') then () else (name($e)),'.',$classOver)"/>
<xsl:sequence select="$css/igs:rule[@selector=$selector]"/>
</xsl:when>
<xsl:when test="$mode='not-override'">
<xsl:variable name="classIndd" select="igs:get-class-indd($e)" as="xs:string"/>
<xsl:variable name="selector" select="concat(if (name($e)='p') then () else (name($e)),'.',$classIndd)"/>
<xsl:sequence select="$css/igs:rule[@selector=$selector]"/>
</xsl:when>
</xsl:choose>
</xsl:function>


Le 02/02/2011 12:14, Martin Honnen a icrit :
Matthieu Ricaud-Dussarget wrote:

I don't really want to return an error node that I'll have to test
afterwards, at best I'd like the xslt processor to raise this error for
me when the passed param has not the good value.

I tried to reproduce the issue with XQSharp and AltovaXML Tools but I couldn't.
Which XSLT processor gives the error?





--
Matthieu Ricaud
IGS-CP
Service Livre numirique

Current Thread