You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Gayda, Joseph J. (LNG)" <Jo...@lexis-nexis.com> on 2001/05/03 15:44:28 UTC

Xerces 1.3.1/Xalan 1.2.1 schema validation question

I'm using the Xalan command line interface and I'm trying to get an example
of XML Schema validation working.  I've included examples below of the
command line syntax, the output, input XML file, stylesheet and schema.
When running in validation mode, what can I do so Xerces doesn't try to open
the URI for the xsl namespace in the stylesheet (or what can I do so that it
validates)?  My attempt to associate the schema with the instance document
doesn't appear to have worked because I'm getting an error for my root XML
element.  I tried to associate the schema with a URI, and I used the
xsi:schemaLocation attribute in the instance document.  No luck.

Here's an example command line:

java org.apache.xalan.xslt.Process -validate -in input.xml -xsl
stylesheet.xsl -out output.xml

***** Here's the output from the command line: *****

========= Parsing file:/stylesheet.xsl ==========
Parser error: General Schema Error: Grammar with uri 2:
http://www.w3.org/1999/XSL/Transform , can not found.
Parser error: Element type "xsl:stylesheet" must be declared.
Parser error: Element type "xsl:template" must be declared.
Parser error: Element type "xsl:copy" must be declared.
Parser error: Element type "xsl:apply-templates" must be declared.
Parser error: Element type "xsl:template" must be declared.
Parser error: Element type "xsl:value-of" must be declared.
Parse of file:/stylesheet.xsl took 8407 milliseconds
========= Parsing file:/input.xml ==========
Parser error: Element type "doc" must be declared.
Parse of file:/input.xml took 777 milliseconds
=============================
Transforming...
transform took 752 milliseconds
XSLProcessor: done

***** Here is the schema file test.xsd: *****

<xsd:schema targetNamespace="http://www.schemas.org/test"
            xmlns:tst="http://www.schemas.org/test"
            xmlns:xsd="http://www.w3.org/2001/XmlSchema"
            elementFormDefault="unqualified"
            attributeFormDefault="unqualified">

<xsd:element name="doc">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
    </xsd:sequence>
    <xsd:anyAttribute/>
  </xsd:complexType>
</xsd:element>

</xsd:schema>

***** Here is the input.xml: *****

<?xml version="1.0"?>
<doc
     xmlns:tst="http://www.schemas.org/test"
     xmlns:xsi="http://www.w3c.org/2000/10/XMLSchema-instance"
     xsi:schemaLocation="tst /home/sinbad/joeg/I2/test.xsd">

</doc>

***** Here is the stylesheet.xsl: *****

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="*|@*">
  <xsl:copy>
    <xsl:apply-templates select="*|@*|text()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="text()">
  <xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org