Schematron rules for NIEM association elements
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 11
- Joined: Mon Mar 21, 2016 4:08 pm
Schematron rules for NIEM association elements
I am trying to build a schematron rule set for an XML structure that contains NIEM association members. For example, I have:
And need to check if the Activity is of some nc:ActivityCategoryText, the Subjects associated with that activity has a given mine:PersonStatus code.
How would I loop through the associations and referance entries across the associations?
Code: Select all
<nc:Activity s:id="Activity1">
<nc:ActivityCategoryText>My new activity</nc:ActivityCategoryText>
.
.
</nc:Activity>
<nc:Activity s:id="Activity2">
<nc:ActivityCategoryText>My second activity</nc:ActivityCategoryText>
.
.
</nc:Activity>
<nc:Subject s:id="Person1">
<mine:PersonStatus>Approved</mine:PersonStatus>
.
.
</nc:Subject>
<nc:Subject s:id="Person2">
<mine:PersonStatus>Dismissed</mine:PersonStatus>
.
.
</nc:Subject>
.
.
.
<mine:ActivitySubjectAssociation>
<nc:Activity s:ref="Activity1"/>
<nc:Subject s:ref="Person1"/>
</mine:AcitvitySubjectAssociation>
[<mine:ActivitySubjectAssociation>
<nc:Activity s:ref="Activity1"/>
<nc:Subject s:ref="Person2"/>
</mine:AcitvitySubjectAssociation>
How would I loop through the associations and referance entries across the associations?
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Schematron rules for NIEM association elements
Hello,
I don't understand exactly what you want to check. Maybe you can give me some real examples, how many persons can be associated with an activity, or how many activities can be associated with a person, maybe you have a schema for the XML file.
If you want to check for example if the persons of a specific activity are approved, you can create a rule like this:
Best Regards,
Octavian
I don't understand exactly what you want to check. Maybe you can give me some real examples, how many persons can be associated with an activity, or how many activities can be associated with a person, maybe you have a schema for the XML file.
If you want to check for example if the persons of a specific activity are approved, you can create a rule like this:
Code: Select all
<sch:pattern>
<sch:rule context="nc:Activities/nc:Activity">
<sch:let name="id" value="@s:id"/>
<sch:let name="personId" value="//mine:ActivitySubjectAssociation[nc:Activity/@s:ref = $id]/nc:Subject/@s:ref"/>
<sch:let name="person" value="//nc:Subject[@s:id=$personId]"/>
<sch:assert test="if (nc:ActivityCategoryText/text()='My new activity') then $person/mine:PersonStatus/text() ='Approved' else true()">
Persons associated with this activity should be approved</sch:assert>
</sch:rule>
</sch:pattern>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 11
- Joined: Mon Mar 21, 2016 4:08 pm
Re: Schematron rules for NIEM association elements
Sorry for the late reply. Yes, there will be several of both with different text and status. Need to check PersonStatus for 'Approved' or 'Pending'. My issue was getting the PersonID for all the people associated with a specific ActivityID. Can you explain the structure of getting the PersonID in your example?
Thanks so much for all your help!!!
Thanks so much for all your help!!!
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: Schematron rules for NIEM association elements
Hello,
If you have a rule with the context set on the "nc:Activity" element, you can execute an XPath expression that will get all activity associations that have the current activity id "//mine:ActivitySubjectAssociation[nc:Activity/@s:ref = $id]". Then from the association you can access the person id using "/nc:Subject/@s:ref" XPath expression.
Best Regards,
Octavian
If you have a rule with the context set on the "nc:Activity" element, you can execute an XPath expression that will get all activity associations that have the current activity id "//mine:ActivitySubjectAssociation[nc:Activity/@s:ref = $id]". Then from the association you can access the person id using "/nc:Subject/@s:ref" XPath expression.
Code: Select all
<sch:let name="allPersonIds" value="//mine:ActivitySubjectAssociation[nc:Activity/@s:ref = $id]/nc:Subject/@s:ref"/>
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