Schematron - Counting number of elements+attributes
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 11
- Joined: Thu Nov 21, 2013 3:34 pm
Schematron - Counting number of elements+attributes
Hi,
I have a strange problem in schematron - I need to create a role that an element with certain attribute value should occur in the XML exactly once. I created the following rule, but it doesn't show an error when the number of elements with 'en' attributes value is more than 1. However, if I change the constrain to e.g. 3, then it does show en error when there are only 2 of them. What am I doing wrong?
My rule:
This doesn't work either:
This XML instance should be incorrect - the name in one language should appear only once:
Thanks in advance for any help,
Ewa
I have a strange problem in schematron - I need to create a role that an element with certain attribute value should occur in the XML exactly once. I created the following rule, but it doesn't show an error when the number of elements with 'en' attributes value is more than 1. However, if I change the constrain to e.g. 3, then it does show en error when there are only 2 of them. What am I doing wrong?
My rule:
Code: Select all
<sch:pattern>
<sch:rule context="//description/functionalName/@languageCode">
<sch:assert test="count(.='en') = 1">The value of Type must be set to a valid GS1 document name</sch:assert>
</sch:rule>
</sch:pattern>
This doesn't work either:
Code: Select all
<sch:pattern>
<sch:rule context="//description">
<sch:assert test="count(functionalName/@languageCode='en') = 1">The value of Type must be set to a valid GS1 document name</sch:assert>
</sch:rule>
</sch:pattern>
Code: Select all
<description>
<functionalName languageCode='sv'/>
<functionalName languageCode='sv'/>
</description>
Thanks in advance for any help,
Ewa
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Schematron - Counting number of elements+attributes
Hello,
You can create a rule for the description element that checks the number of functionalName elements that have the @languageCode equal with 'en', something like this:
Best Regards,
Octavian
You can create a rule for the description element that checks the number of functionalName elements that have the @languageCode equal with 'en', something like this:
Code: Select all
<sch:pattern>
<sch:rule context="description">
<sch:assert test="count(functionalName[@languageCode= 'en']) = 1">The value of Type must be set to a valid GS1 document name</sch:assert>
</sch:rule>
</sch:pattern>
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