Problem with ISO Schematron/XPath 2.0
Posted: Thu Dec 18, 2008 9:58 pm
hi guys,
It's been awhile since I've used Schematron and I'm pretty shaky on Xpath 2.0.
I'm having a problem getting the attached ISO Schematron to compile relative to the attached xml instance doc. It doesn't like my use of namespace prefixes, and my XPath expression is evidently bad.
I'm sure I'm doing something(s) stupid. Can you tell me what it is?
John
===========
Schematron:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
xmlns:iso="http://purl.oclc.org/dsdl/schematron">
<iso:pattern id="calculate-N-stage" xmlns:colon="http://www.cap.org/pert/2009/01/colon/"
xmlns:pert="http://www.cap.org/pert/2009/01/">
<iso:rule context="pert:N/@value">
<iso:let name="posNodes" value="sum(//pert:nodeGroup/@positiveNodes)"/>
<iso:let name="N" value="//pert:N/@value"/>
<iso:assert test="if (posNodes = 0) then N = 0 else if (posNodes < 4)
then N = 1 else N = 2">Value of N-stage does not match the number of positive
nodes.</iso:assert>
</iso:rule>
</iso:pattern>
</schema>
===================
Instance:
<?xml version="1.0" encoding="UTF-8"?>
<?oxygen SCHSchema="N.sch"?>
<synopsis pert:schemaLocation="http://www.cap.org/pert/2009/01/resection@colon.rng"
pert:version="2009-01-01" xmlns="http://www.cap.org/pert/2009/01/"
xmlns:colon="http://www.cap.org/pert/2009/01/colon/"
xmlns:pert="http://www.cap.org/pert/2009/01/">
<comment xml:lang="en">This synopsis demonstrates the resection@colon.rng schema</comment>
<displayText>SYNOPTIC REPORT</displayText>
<clinical>
<comment>Might want to provide wrapper for free text</comment>
<displayText>Clinical History</displayText>
<priorTherapies>
<priorTherapy date="2008-05" description="Chemoirradiation"/>
</priorTherapies>
</clinical>
<specimen>
<displayText>Specimen</displayText>
<procedures>
<procedure value="abdominoperineal resection">
<comment>In this example this procedure was an A-P resection</comment>
</procedure>
</procedures>
<sites>
<displayText>What is the site?</displayText>
<site value="rectum"/>
<site value="sigmoidColon"/>
</sites>
<tumorLocations>
<tumorLocation value="rectum"/>
</tumorLocations>
<colon:polyp>
<colon:hasConfiguration value="pedunculated"/>
<colon:hasSize unit="cm" value="1.3"/>
</colon:polyp>
<colon:specimenIntegrity value="fragmented"/>
<colon:specimenLength unit="cm" value="23"/>
</specimen>
<tumor>
<histologicTypes>
<histologicType value="adenocarcinoma"/>
</histologicTypes>
<grade gradingSystem="WHO" value="high"/>
<colon:immuneResponse>
<colon:intratumoralResponse value="marked"/>
<colon:peritumoralResponse value="marked"/>
</colon:immuneResponse>
<colon:suggestMicrosatelliteInstability>
<colon:highGrade value="false"/>
<colon:medullaryComponent value="true"/>
<colon:mucinousComponent percentage="50" value="true"/>
</colon:suggestMicrosatelliteInstability>
<colon:tumorPerforation value="false"/>
</tumor>
<extent>
<colon:invasion>
<colon:deepestInvasion value="muscularisPropria"/>
<colon:adjacentStructure value="pelvic sidewall"/>
</colon:invasion>
<tumorSize dimension-1="2.1" dimension-2="1.7" dimension-3="1.2" unit="cm"/>
</extent>
<accessory>
<colon:preexistingPolyp value="serratedAdenoma"/>
<colon:discontinuousExtramuralExtension value="false"/>
<lymphovascularInvasion value="inconclusive"/>
<perineuralInvasion value="inconclusive"/>
<venousInvasion value="false"/>
<treatmentEffect value="slightResponse"/>
</accessory>
<margins>
<margin location="proximal" status="negative"/>
<margin location="distal" status="negative"/>
<margin location="circumferential" status="negative"/>
</margins>
<nodes>
<nodeGroup laterality="right" location="anorectal" positiveNodes="1" totalNodes="5"/>
<nodeGroup laterality="right" location="anterior cecal" positiveNodes="2" totalNodes="6"/>
</nodes>
<stage>
<classification value="p"/>
<T value="2"/>
<N value="0"/>
<M value="X"/>
<prefix value="a r y"/>
</stage>
</synopsis>
It's been awhile since I've used Schematron and I'm pretty shaky on Xpath 2.0.
I'm having a problem getting the attached ISO Schematron to compile relative to the attached xml instance doc. It doesn't like my use of namespace prefixes, and my XPath expression is evidently bad.
I'm sure I'm doing something(s) stupid. Can you tell me what it is?
John
===========
Schematron:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron"
xmlns:iso="http://purl.oclc.org/dsdl/schematron">
<iso:pattern id="calculate-N-stage" xmlns:colon="http://www.cap.org/pert/2009/01/colon/"
xmlns:pert="http://www.cap.org/pert/2009/01/">
<iso:rule context="pert:N/@value">
<iso:let name="posNodes" value="sum(//pert:nodeGroup/@positiveNodes)"/>
<iso:let name="N" value="//pert:N/@value"/>
<iso:assert test="if (posNodes = 0) then N = 0 else if (posNodes < 4)
then N = 1 else N = 2">Value of N-stage does not match the number of positive
nodes.</iso:assert>
</iso:rule>
</iso:pattern>
</schema>
===================
Instance:
<?xml version="1.0" encoding="UTF-8"?>
<?oxygen SCHSchema="N.sch"?>
<synopsis pert:schemaLocation="http://www.cap.org/pert/2009/01/resection@colon.rng"
pert:version="2009-01-01" xmlns="http://www.cap.org/pert/2009/01/"
xmlns:colon="http://www.cap.org/pert/2009/01/colon/"
xmlns:pert="http://www.cap.org/pert/2009/01/">
<comment xml:lang="en">This synopsis demonstrates the resection@colon.rng schema</comment>
<displayText>SYNOPTIC REPORT</displayText>
<clinical>
<comment>Might want to provide wrapper for free text</comment>
<displayText>Clinical History</displayText>
<priorTherapies>
<priorTherapy date="2008-05" description="Chemoirradiation"/>
</priorTherapies>
</clinical>
<specimen>
<displayText>Specimen</displayText>
<procedures>
<procedure value="abdominoperineal resection">
<comment>In this example this procedure was an A-P resection</comment>
</procedure>
</procedures>
<sites>
<displayText>What is the site?</displayText>
<site value="rectum"/>
<site value="sigmoidColon"/>
</sites>
<tumorLocations>
<tumorLocation value="rectum"/>
</tumorLocations>
<colon:polyp>
<colon:hasConfiguration value="pedunculated"/>
<colon:hasSize unit="cm" value="1.3"/>
</colon:polyp>
<colon:specimenIntegrity value="fragmented"/>
<colon:specimenLength unit="cm" value="23"/>
</specimen>
<tumor>
<histologicTypes>
<histologicType value="adenocarcinoma"/>
</histologicTypes>
<grade gradingSystem="WHO" value="high"/>
<colon:immuneResponse>
<colon:intratumoralResponse value="marked"/>
<colon:peritumoralResponse value="marked"/>
</colon:immuneResponse>
<colon:suggestMicrosatelliteInstability>
<colon:highGrade value="false"/>
<colon:medullaryComponent value="true"/>
<colon:mucinousComponent percentage="50" value="true"/>
</colon:suggestMicrosatelliteInstability>
<colon:tumorPerforation value="false"/>
</tumor>
<extent>
<colon:invasion>
<colon:deepestInvasion value="muscularisPropria"/>
<colon:adjacentStructure value="pelvic sidewall"/>
</colon:invasion>
<tumorSize dimension-1="2.1" dimension-2="1.7" dimension-3="1.2" unit="cm"/>
</extent>
<accessory>
<colon:preexistingPolyp value="serratedAdenoma"/>
<colon:discontinuousExtramuralExtension value="false"/>
<lymphovascularInvasion value="inconclusive"/>
<perineuralInvasion value="inconclusive"/>
<venousInvasion value="false"/>
<treatmentEffect value="slightResponse"/>
</accessory>
<margins>
<margin location="proximal" status="negative"/>
<margin location="distal" status="negative"/>
<margin location="circumferential" status="negative"/>
</margins>
<nodes>
<nodeGroup laterality="right" location="anorectal" positiveNodes="1" totalNodes="5"/>
<nodeGroup laterality="right" location="anterior cecal" positiveNodes="2" totalNodes="6"/>
</nodes>
<stage>
<classification value="p"/>
<T value="2"/>
<N value="0"/>
<M value="X"/>
<prefix value="a r y"/>
</stage>
</synopsis>