Version Validation
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 3
- Joined: Fri Jul 24, 2020 3:34 pm
Version Validation
Hi Team,
I have a requirement to validate an XML using Xpath Schematron based on the Version.
Posting a sample below.
<root>
<Node1 version="1">
<Element1>Value1</Element1>
<Type>123456</Type>
</Node1>
<Node1 version="2">
<Element1>Value1</Element1>
<Type>123456</Type>
</Node1>
<Node1 version="3">
<Element1>Value1</Element1>
<Type>1234567</Type>
</Node1>
</root>
I have a requirement to fetch the min value of the version element and then fetch the Value of Type Element for the min version and need to validate as the Type element Value should be the same for remaining versions.
So Technically value of Version 3 should fail and the Type Element value does not equals the one with Version 1 element.
I am new to Xpath Schematron, Can you help me figure out a way.
Thanks in advance.
I have a requirement to validate an XML using Xpath Schematron based on the Version.
Posting a sample below.
<root>
<Node1 version="1">
<Element1>Value1</Element1>
<Type>123456</Type>
</Node1>
<Node1 version="2">
<Element1>Value1</Element1>
<Type>123456</Type>
</Node1>
<Node1 version="3">
<Element1>Value1</Element1>
<Type>1234567</Type>
</Node1>
</root>
I have a requirement to fetch the min value of the version element and then fetch the Value of Type Element for the min version and need to validate as the Type element Value should be the same for remaining versions.
So Technically value of Version 3 should fail and the Type Element value does not equals the one with Version 1 element.
I am new to Xpath Schematron, Can you help me figure out a way.
Thanks in advance.
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Version Validation
Hello,
For this type of questions probably is better to use the "schematron at schematronist dot org" mailing list. There are more people that can respond to them, and maybe better answers.
I think that a solution for your Schematron rule can be something like this:
Best Regards,
Octavian
For this type of questions probably is better to use the "schematron at schematronist dot org" mailing list. There are more people that can respond to them, and maybe better answers.
I think that a solution for your Schematron rule can be something like this:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<sch:let name="typeValue" value="//Node1[not(@version > ../Node1/@version)][1]/Type/text()"/>
<sch:pattern>
<sch:rule context="Type">
<sch:assert test="text() = $typeValue">
The Type value must be "<sch:value-of select="$typeValue"/>"
</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)
- ↳ 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