xsl-list
[Top] [All Lists]

RE: [xsl] checking sequence inside processing-instruction

2008-07-03 02:15:41

<?page 5?>
<?page 6?>
<?page 8?>

The style sheet should tell <?page 8?> is out of sequence.


Assuming you are applying templates to processing instructions:

<xsl:template match="processing-instruction('page')">
  <xsl:if test="preceding::processing-instruction('page')[1][number(.) &gt;=
number(current())]">
    <xsl:message>error</xsl:message>
  </xsl:if>
</xsl:template>

(The call to number() isn't needed in XSLT 1.0. It is needed in 2.0, because
otherwise the values will be compared as strings. The condition will always
be false if the value is non-numeric, you might want a different error
message for that case. The predicate [1] is for performance reasons only.)

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--