WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

active:jingValidate

Endpoint
Name:jingValidate
Description:A multi-schema XML validation engine
Id:jing.validator
Category:accessor
Identifier Syntax

jingValidate is an accessor using Active URI syntax with the following base identifiers:

Base
active:jingValidate

and the following arguments: (for more details on argument passing details see here)

ArgumentRulesTypingDescription
operator
Mandatory
Representation (java.lang.Object)(no description available)
operand
Mandatory
Representation (java.lang.Object)(no description available)
errorsink
Optional
Representation (java.lang.Object)(no description available)
xmlmode
Optional
Defaults to "false"
Identifier(no description available)
Request Verbs

The following verb is supported:

Verb
SOURCE
Response

The response representation of this accessor for SOURCE requests is unknown.

This accessor throws no documented exceptions.

Import Requirements

To use jingValidate accessor you must import the module urn:org:netkernel:xml:jing:

<import>
  <uri>urn:org:netkernel:xml:jing</uri>
</import>

The active:jingValidate service is an XML validation engine that supports several schema languages including

Syntax

The syntax for the service is:

Resource Identifier Syntax

active:jingValidate
+ operator @ [ the schema ]
+ operand @ [ the XML resource to be validated ]
+ xmlmode @ [ when resource identifier is "true" use XML Mode (see below) ] *
+ errorsink @ [ When not in xmlmode, a resource, that if specified will have error report SINKed to it ] *

SOURCE

The accessor has two modes. In default "POJO" mode, the validator returns a java.lang.Boolean representation.

When the xmlmode argument is present the validator responds with an XML resource having the following form.

<b>true|false
  <errors>...error and/or report messages...</errors>
</b>

The form of the block is the same as described in the Error handling section below.

Schema Type Determination

The Jing engine uses the namespace of the root element of the schema resource to determine the validation language to use. The choices are

RelaxNG http://relaxng.org/ns/structure/1.0
Schematron http://www.ascc.net/xml/schematron
XML Schema http://www.w3.org/2001/XMLSchema
NRL http://www.thaiopensource.com/validate/nrl

Error Handling

Errors are reported with an XML resource with following form...

<errors>
  <error>
    <message>unknown element "bad"</message>
    <line>6</line>
    <column>8</column>
    <systemId>res:/test/docs/doc2.xml</systemId>
  </error>
  <warning />
  <report />
  <fatalerror />
</errors>

The child of errors may be error, warning, report, fatalerror. In each case a message, line and column and the document systemId will be provided.

When using Schematron then report may be present even when the document is valid.

The following error handling will occur depending on mode.

POJO Mode

If an errorsink argument is specified then the errors will be SINKed to that resource. If no errorsink is specified then the errors are logged at level FINE.

XML Mode

will be present in the XML output of the accessor and will contain error, warning, report, fatalerror if they have occured.

ROC Entity Resolution

The schema compiler and runtime each provide a NKFEntityResolver to Jing for resolution of external entities in the ROC address space.

So for example, in RelaxNG, externalRef imports will be resolved the ROC domain.

XSD Limitation

At present is seems that when using XML Schemas entity resolution is not using the supplied resolver - if you need to resolve XSD entities in the ROC domain then you should look at the active:validateXSD validator in the xml:core library.

Examples

Suppose we have the following document (called res:/doc.xml)

<addressBook>
  <card>
    <name>John Smith</name>
    <email>js@example.com</email>
  </card>
  <card>
    <name>Fred Bloggs</name>
    <email>fb@example.net</email>
  </card>
</addressBook>

Here's how we could validate it using various schema languages and the active:jingValidate engine.

RelaxNG

To validate doc.xml with the following RelaxNG schema (called res:/doc-relax.rng)

<element xmlns="http://relaxng.org/ns/structure/1.0" name="addressBook">
  <zeroOrMore>
    <element name="card">
      <element name="name">
        <text />
      </element>
      <element name="email">
        <text />
      </element>
    </element>
  </zeroOrMore>
</element>

in NKF syntax in POJO mode...

req=context.createRequest("active:jingValidate");
req.addArgument("operand", "res:/doc.xml");
req.addArgument("operator", "res:/doc-relax.rng");
valid=context.issueRequest(req);

Here valid will be boolean true.

XML Mode Example

XML mode in NKF syntax...

req=context.createRequest("active:jingValidate");
req.addArgument("operand", "res:/doc.xml");
req.addArgument("operator", "res:/doc-relax.rng");
req.addArgument("xmlmode", "true");
valid=context.issueRequest(req);

Here valid will be the XML resource...

<b>true
  <errors />
</b>

Schematron

To validate doc.xml with the following Schematron schema (called res:/doc-schematron.xml)

<schema xmlns="http://www.ascc.net/xml/schematron">
  <pattern name="Simple Schematron">
    <rule context="addressBook">
      <assert test="card">card element is missing.</assert>
    </rule>
    <rule context="addressBook/card">
      <assert test="name">name element is missing.</assert>
      <assert test="email">email element is missing.</assert>
    </rule>
  </pattern>
</schema>

in NKF syntax...

req=context.createRequest("active:jingValidate");
req.addArgument("operand", "res:/doc.xml");
req.addArgument("operator", "res:/doc-schematron.xml");
valid=context.issueRequest(req);