<xsl:template match="CONSTRAINT">
<xsl:variable name="cc">
<xsl:apply-templates select="CC"/>
</xsl:variable>
<xsl:variable name="sel" select="SELECTOR/@SELEXP"/>
<xsl:variable name="pred">
<xsl:apply-templates select="CC/VARIABLE" mode="pred"/>
<xsl:variable>
<xsl:comment>
.....................NEW CONSTRAINT.....................
</xsl:comment>
<my:template mode="constraint{count(preceding-sibling::*)+1}"
match="{$sel}{$pred}">
<my:if test="not({$cc})">
<err-message>
<xsl:apply-templates select="ACTION"/>
</err-message>
</my:if>
</my:template>
<my:template match="text()" priority="-1"
mode="constraint{count(preceding-sibling::*)+1}">
<!-- strip characters -->
</my:template>
</xsl:template> |
<?xml version="1.0"?>
<cd>
...
<price>32.00
...
</cd> |
<?xml version="1.0"?> <CS> <CONSTRAINT> <SELECTOR SELEXP="/cd/price"/> <CC>(.>0) and (.<100) <ACTION> <MESSAGE>Price out of range! </ACTION> </CONSTRAINT> </CS> |
<xsl:stylesheet version="1.0">
<xsl:template match="/">
<doc-status>
<xsl:apply-templates mode="constraint1"/>
</doc-status>
</xsl:template>
<!--...................NEW CONSTRAINT.....................-->
<xsl:template mode="constraint1" match="/cd/price">
<xsl:if test="not((.>0) and (.<100))">
<err-message>Price out of range!
</xsl:if>
</xsl:template>
<xsl:template match="text()" priority="-1" mode="constraint1"/>
<xsl:template match="text()" priority="-1"/>
</xsl:stylesheet> |