Unique combination of element / attribute value in schematron
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 11
- Joined: Thu Nov 21, 2013 3:34 pm
Unique combination of element / attribute value in schematron
Hi,
I have a problem that seems to be quite common, but none of the examples I found, actually works for me. The rule needs to say that the combination of element and attribute value must beunique. There can be only one instance of a name per language, but the name can be the same for different languages:
The rule I created is the following:
But it always gives an error, so there must be something wrong with it.
Could you give me some suggestion?
Thank you,
Ewa
I have a problem that seems to be quite common, but none of the examples I found, actually works for me. The rule needs to say that the combination of element and attribute value must beunique. There can be only one instance of a name per language, but the name can be the same for different languages:
Code: Select all
<brandName>
<languageSpecificBrandName language='en'>name1</languageSpecificBrandName>
<languageSpecificBrandName language='fr'>name2</languageSpecificBrandName>
<languageSpecificBrandName language='de'>name2</languageSpecificBrandName>
</brandName>
Code: Select all
<sch:rule context="//brandName">
<sch:assert test="count(languageSpecificBrandName/@languageCode[.=current()])=1">Error</sch:assert>
</sch:rule>
Could you give me some suggestion?
Thank you,
Ewa
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Unique combination of element / attribute value in schematron
Hello,
You can create a rule that for each languageSpecificBrandName element verifies that there is no previous sibling with the same name and language code. The rule must be something like this:
Best Regards,
Octavian
You can create a rule that for each languageSpecificBrandName element verifies that there is no previous sibling with the same name and language code. The rule must be something like this:
Code: Select all
<sch:rule context="languageSpecificBrandName">
<sch:let name="currentLang" value="@language"/>
<sch:let name="currentName" value="text()"/>
<sch:assert test="count(preceding-sibling::languageSpecificBrandName[@language=$currentLang and text() = $currentName])=0">
Combination lang of '<sch:value-of select="$currentLang"/>' and name '<sch:value-of select="$currentName"/>' already used.
</sch:assert>
</sch:rule>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “General XML Questions”
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