Looping in schematron
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 157
- Joined: Mon Aug 18, 2014 4:11 pm
Looping in schematron
Hi team,
I would like to create a schematron rule which can be looped through the element content. The need is that I need to check the number of characters before a line break and should loop through the content finding next line break. This is for pre-formatted elements. The warning is for adding more number of characters in a line than allowed.
I have done below coding but it works only for one line break:
Please let me know if you have a way forward for me on this
Thanks,
Shabeer
I would like to create a schematron rule which can be looped through the element content. The need is that I need to check the number of characters before a line break and should loop through the content finding next line break. This is for pre-formatted elements. The warning is for adding more number of characters in a line than allowed.
I have done below coding but it works only for one line break:
Code: Select all
<pattern>
<rule id="1" context="*[contains(@class,'- topic/pre ')]">
<assert test="string-length(substring-before(.,' ')) < 50 " role="warning"> Do not exceed number of characters in a line in pre than 50
</assert>
</rule>
</pattern>
Thanks,
Shabeer
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Looping in schematron
Hi Shabeer,
You need to determine each line of text from your "pre" element and check its length. I have created a sample for you using XSLT to determine the lines of text. You can find the sample below:
Best Regards,
Octavian
You need to determine each line of text from your "pre" element and check its length. I have created a sample for you using XSLT to determine the lines of text. You can find the sample below:
Code: Select all
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<sch:pattern>
<sch:rule context="*[contains(@class, '- topic/pre ')]">
<xsl:variable name="offendingLines">
<xsl:for-each select="tokenize(text(), ' ')">
<xsl:if test="string-length(current()) > 50">
<xsl:value-of select="concat(position(), ', ')"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<sch:report test="string-length($offendingLines) > 0"> Lines (<sch:value-of
select="$offendingLines"/>) in pre should not exceed 50 characters.
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service