xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: "Greg Saunders" <saundersgreg AT hotmail.com>
- To: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] xml:lang and the xml prefix
- Date: Thu, 02 Dec 2004 14:59:21 -0500
Hi,
Apologies if I am not sending this email correctly, or if this question has already been answered. (Is the email list archive [1] searchable on the web?)
I would like to write an XML instance document that is valid against an XML schema.
Here is the XML schema (note that I import the XML namespace to reference its xml:lang attribute), translation.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns="http://www.myexample.org/"
targetNamespace="http://www.myexample.org/"
>
<xsd:import
namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd"
/>
<xsd:element name="translation" type="TranslationType"/>
<xsd:complexType name="TranslationType">
<xsd:sequence>
<xsd:element name="h" type="xsd:string"/>
<xsd:element name="p" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute ref="xml:lang" use="required"/>
<xsd:attribute name="original" type="xsd:boolean" use="required"/>
</xsd:complexType>
</xsd:schema>
Here is the XML instance document (note that I'm using the common xml:lang attribute), translation-en.xml:
<cc:translation
xmlns:cc="http://www.myexample.org/"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xml:lang="en"
original="true"
>
<h>This is a heading</h>
<p>This is a paragraph that belongs to the heading</p>
<p>This is another paragraph belonging to the same heading</p>
</cc:translation>
But following the directions in the XOM tutorial [2]. . .
try {
Builder parser = new Builder();
Document doc = parser.build("http://www.myexample.org/translation-en.xml");
}
catch (ParsingException ex) {
System.err.println("The translation is malformed today. How embarrassing!");
}
catch (IOException ex) {
System.err.println("Could not connect to www.myexample.org. The site may be down.");
}
. . . I get:
nu.xom.ParsingException: Illegal Namespace prefix: "xml". at line 6, column -1.
Why is my "xml" prefix illegal? Do I really have to re-invent the "lang" attribute?
(The exception mysteriously disappears when I include (the Xerces 2.6.2) xercesImpl.jar in the runtime classpath.)
[1] https://lists.ibiblio.org/sympa/arc/xom-interest/
[2] http://www.cafeconleche.org/XOM/tutorial.xhtml#d0e415
-
[XOM-interest] xml:lang and the xml prefix,
Greg Saunders, 12/02/2004
- Re: [XOM-interest] xml:lang and the xml prefix, Elliotte Harold, 12/02/2004
Archive powered by MHonArc 2.6.24.