How to get embedded Schematron to work?
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 3
- Joined: Thu Apr 09, 2009 4:53 pm
How to get embedded Schematron to work?
Post by PetrolDave »
I've been working on a XSD file for a while and realised today that I need to embed Schematron to do some of the checks needed. I've followed the (few) examples I can find but the Schemtron doesn't seem to run.
Here's a segment of the xsd:
<!-- ?xml version="1.0" encoding="ISO-8859-1"? -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sch="http://www.ascc.net/xml/Schematron"
elementFormDefault="qualified">
<!-- Setup Schematron -->
<xsd:annotation>
<xsd:appinfo>
<sch:title>Schematron validation</sch:title>
<sch:ns prefix="v" uri="sample.xsd"/>
</xsd:appinfo>
</xsd:annotation>
<!-- Define the root and the uniqueness rules -->
<xsd:element name="root" type="RootType">
<!-- Define Schematron pattern(s) -->
<xsd:annotation>
<xsd:appinfo>
<sch:pattern name="Check Trunk Card names in Trunks">
<sch:rule context="v:.//trunk_card">
<sch:assert test="v:name == v:trunk/trunk_card_name"
diagnostics="TrunkCardName">
must match
</sch:assert>
</sch:rule>
</sch:pattern>
<sch:diagnostic id="TrunkCardName">
Error! does not match
trunk_card[]/name =
<sch:value-of select="v:name"/>
trunk_card[]/trunk[]/trunk_card_name =
<sch:value-of select="v:trunk/trunk_card_name"/>
</sch:diagnostic>
</xsd:appinfo>
</xsd:annotation>
...
</xsd:/element>
</xsd:schema>
And the xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?oxygen SCHSchema="sample.xsd"?>
...
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sample.xsd">
<trunk_card enabled="Yes">
<name>Trunk Card 2</name>
<trunk enabled="Yes">
<name>First Trunk</name>
<trunk_card_name>Trunk Card 1</trunk_card_name>
<trunk_number>0</trunk_number>
</trunk>
<trunk enabled="Yes">
<name>Second Trunk</name>
<trunk_card_name>Trunk Card 1</trunk_card_name>
<trunk_number>7</trunk_number>
</trunk>
</trunk_card>
...
</root>
The xml has the trunk_card/trunk/trunk_card_name elements deliberately set to be different to the trunk_card/name parent - but the Schematron doesn't report the error???
I'm a complete novice to Schematron, so be kind if I'm doing something silly!
Here's a segment of the xsd:
<!-- ?xml version="1.0" encoding="ISO-8859-1"? -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sch="http://www.ascc.net/xml/Schematron"
elementFormDefault="qualified">
<!-- Setup Schematron -->
<xsd:annotation>
<xsd:appinfo>
<sch:title>Schematron validation</sch:title>
<sch:ns prefix="v" uri="sample.xsd"/>
</xsd:appinfo>
</xsd:annotation>
<!-- Define the root and the uniqueness rules -->
<xsd:element name="root" type="RootType">
<!-- Define Schematron pattern(s) -->
<xsd:annotation>
<xsd:appinfo>
<sch:pattern name="Check Trunk Card names in Trunks">
<sch:rule context="v:.//trunk_card">
<sch:assert test="v:name == v:trunk/trunk_card_name"
diagnostics="TrunkCardName">
must match
</sch:assert>
</sch:rule>
</sch:pattern>
<sch:diagnostic id="TrunkCardName">
Error! does not match
trunk_card[]/name =
<sch:value-of select="v:name"/>
trunk_card[]/trunk[]/trunk_card_name =
<sch:value-of select="v:trunk/trunk_card_name"/>
</sch:diagnostic>
</xsd:appinfo>
</xsd:annotation>
...
</xsd:/element>
</xsd:schema>
And the xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?oxygen SCHSchema="sample.xsd"?>
...
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="sample.xsd">
<trunk_card enabled="Yes">
<name>Trunk Card 2</name>
<trunk enabled="Yes">
<name>First Trunk</name>
<trunk_card_name>Trunk Card 1</trunk_card_name>
<trunk_number>0</trunk_number>
</trunk>
<trunk enabled="Yes">
<name>Second Trunk</name>
<trunk_card_name>Trunk Card 1</trunk_card_name>
<trunk_number>7</trunk_number>
</trunk>
</trunk_card>
...
</root>
The xml has the trunk_card/trunk/trunk_card_name elements deliberately set to be different to the trunk_card/name parent - but the Schematron doesn't report the error???
I'm a complete novice to Schematron, so be kind if I'm doing something silly!
-
- Posts: 3
- Joined: Thu Apr 09, 2009 4:53 pm
Re: How to get embedded Schematron to work?
Post by PetrolDave »
I think I might have just answered my own question...
I was using xmlns:sch="http://www.ascc.net/xml/Schematron" instead of xmlns:sch="http://purl.oclc.org/dsdl/schematron"
Doh!!!
I was using xmlns:sch="http://www.ascc.net/xml/Schematron" instead of xmlns:sch="http://purl.oclc.org/dsdl/schematron"
Doh!!!
-
- Posts: 3
- Joined: Thu Apr 09, 2009 4:53 pm
Re: How to get embedded Schematron to work?
Post by PetrolDave »
What's wrong with this line?
<sch:rule context=".//v:trunk_card">
I've tried v:.//trunk_card as well as .//v:trunk_card
Sorry for all the questions!
<sch:rule context=".//v:trunk_card">
I've tried v:.//trunk_card as well as .//v:trunk_card
Sorry for all the questions!
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: How to get embedded Schematron to work?
Post by sorin_ristache »
Hello,
v:.//trunk_card is not a valid expression. The expression specified in the context attribute should be relative to the element in which that sch:rule is used.
You did not post a working sample so I cannot offer more help.
Regards,
Sorin
v:.//trunk_card is not a valid expression. The expression specified in the context attribute should be relative to the element in which that sch:rule is used.
You did not post a working sample so I cannot offer more help.
Regards,
Sorin
-
- Posts: 156
- Joined: Sat Feb 26, 2005 12:09 am
- Location: USA
- Contact:
Re: How to get embedded Schematron to work?
Post by shudson310 »
I'm trying to validate a file using Schematron, but am getting a bunch of errors reported on the schematron file. It works in jnvdl, but can't seem to get it working in oXygen? Does oXygen support schematron like:
<?xml version="1.0"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:regexp="http://exslt.org/regular-expressions"
queryBinding="xslt2"
>
<title>Grammar (Schematron Layer)</title>
<ns uri="http://www.w3.org/1998/Math/MathML" prefix="m"/>
<ns uri="http://www.w3.org/2005/xpath-functions" prefix="fn"/>
<ns uri="http://exslt.org/regular-expressions" prefix="regexp"/>
Some errors I get are:
SystemID: C:\projects\rules.sch
Engine name: oNVDL
Severity: error
Description: Error in expression foo:bar[@type eq 'baz']: expected "]", found "<name>"
I think that's a valid expression? (assuming the namespaces are all declared).
Thanks,
--Scott
<?xml version="1.0"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:regexp="http://exslt.org/regular-expressions"
queryBinding="xslt2"
>
<title>Grammar (Schematron Layer)</title>
<ns uri="http://www.w3.org/1998/Math/MathML" prefix="m"/>
<ns uri="http://www.w3.org/2005/xpath-functions" prefix="fn"/>
<ns uri="http://exslt.org/regular-expressions" prefix="regexp"/>
Some errors I get are:
SystemID: C:\projects\rules.sch
Engine name: oNVDL
Severity: error
Description: Error in expression foo:bar[@type eq 'baz']: expected "]", found "<name>"
I think that's a valid expression? (assuming the namespaces are all declared).
Thanks,
--Scott
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
Staff Content Engineer
Site: docs.servicenow.com
Re: How to get embedded Schematron to work?
Hi Scott,
oXygen supports pre ISO Schematron and ISO Schematron, both as standalone schemas and embedded in XML Schema or Relax NG. However, it seems you are trying to use that from NVDL and oNVDL does not support ISO Schematron.
I integrated the NVDL support from oNVDL into the new jing-trang project where support for ISO Schematron is high on the todo list:
http://code.google.com/p/jing-trang/issues/detail?id=23
oXygen starting with its next release will integrate the new jing-trang instead of oNVDL so as soon as that will be implemented it will be available also from within oXygen.
Best Regards,
George
oXygen supports pre ISO Schematron and ISO Schematron, both as standalone schemas and embedded in XML Schema or Relax NG. However, it seems you are trying to use that from NVDL and oNVDL does not support ISO Schematron.
I integrated the NVDL support from oNVDL into the new jing-trang project where support for ISO Schematron is high on the todo list:
http://code.google.com/p/jing-trang/issues/detail?id=23
oXygen starting with its next release will integrate the new jing-trang instead of oNVDL so as soon as that will be implemented it will be available also from within oXygen.
Best Regards,
George
George Cristian Bina
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