Schematron and Namespaces

Roger Costello

Click arrow key () to navigate to next page

Namespaces

Example

  1. <?xml version="1.0"?>
  2. <Document xmlns="http://www.example.org"
  3. classification="secret">
  4. <Para classification="unclassified">
  5. One if by land, two if by sea;
  6. </Para>
  7. </Document>

Specifying the Namespace

  1. <?xml version="1.0"?>
  2. <sch:schema xmlns:sch="http://www.ascc.net/xml/schematron">
  3. <sch:ns uri="http://www.example.org"
  4. prefix="ex" />
  5. <sch:pattern name="Security Classification Policy">...</sch:pattern>
  6. </sch:schema>

Rule

  1. <sch:rule context="ex:Para[@classification='top-secret']">
  2. ...
  3. </sch:rule>

Assertion

  1. <sch:assert test="/ex:Document/@classification='top-secret'">
  2. ...
  3. </sch:assert>

Schematron Schema

Validate

Lab 5

Homepage