Schermatron: matching element element content with other element name
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 11
- Joined: Thu Nov 21, 2013 3:34 pm
Schermatron: matching element element content with other element name
Hi,
I have the following XML document:
and need to write a schematron assertion testing that the text in element1: SmomeName matches the tag name of element4, without the namespace prefix. The SomeText and element tag name are different in every document.
I figured out that I need to point to the 2nd child of <element2> and probably use the NCName, but I have no idea how to put it all together.
Alternatively, I could point to the sibling of <element3>, which is always the same, but still I don't knoiw how to get the name of <element4>. None of the variants I tried worked so far.
Every help will be appreciated.
Ewa
I have the following XML document:
Code: Select all
<abc:root xmlns:abc="urn:xyz:abc" xmlns:hij="urn:xyz:def">
<element1>SomeName</element1>
<element2>
<element3>SomeText</element3>
<hij:element4>
<someMoreElements/>
</hij:element4>
</element2>
</abc:root>
I figured out that I need to point to the 2nd child of <element2> and probably use the NCName, but I have no idea how to put it all together.
Alternatively, I could point to the sibling of <element3>, which is always the same, but still I don't knoiw how to get the name of <element4>. None of the variants I tried worked so far.
Every help will be appreciated.
Ewa
-
- Posts: 391
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Schermatron: matching element element content with other element name
Hello,
For the example that you provided You need to create a Schematron something like this:
Best Regards,
Octavian
For the example that you provided You need to create a Schematron something like this:
Code: Select all
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<sch:pattern>
<sch:rule context="element1">
<sch:let name="matchElemName" value="following-sibling::*[1]/child::*[2]/local-name()"/>
<sch:assert test="text() = $matchElemName">
The name of the elemnt must be '<sch:value-of select="text()"/>', but is '<sch:value-of select="$matchElemName"/>'
</sch:assert>
</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)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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