Using Schematron to Define Space as the First Character in an Element

Is it possible to write a schema rule / assertion that will identify the whitespace at the beginning of an element? I need a way to mark elements that start with a spot for possible space removal, but I don't want to force such spaces through XSLT, etc. Here's an example:

<section>
<paragraph> Here some text.</paragraph>
</section>

      

+3


source to share


1 answer


Yes, Schematron uses XPath for assertions, so testing the string value of an element for a leading space is very easy:



  <pattern>
    <title>Paragraphs starting with a space</title>
    <rule context="paragraph">
      <report test="starts-with(., ' ')">
        This paragraph starts with a space: <value-of select="paragraph"/>
      </report>
    </rule>
  </pattern>

      

+3


source







All Articles