xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
[XOM-interest] Cannot find the declaration of element...
- From: "Jacobs, Robert A." <ra.jacobs AT ngc.com>
- To: "XOM (E-mail)" <xom-interest AT lists.ibiblio.org>
- Subject: [XOM-interest] Cannot find the declaration of element...
- Date: Wed, 9 Mar 2005 15:07:47 -0600
XOM-interest members,
I bought the 3rd Edition of Elliotte's "XML in a Nutshell" and, with
book in
hand, have been wading my way through the world of XML for a project
I've recently been assigned.
I've run into a problem and am not sure what the solution is:
"cvc-elt.1: Cannot find the declaration of element
'jtt:apprentice_tasks'."
It appears that the xsd file is not being found.
************************************************************************
System Configuration
************************************************************************
Here is my system configuration:
JDK 1.5.0_01
- I originally wanted the JAXP 1.3 features
JBOSS 4.0.1sp1
- upgrading to JDK 1.5.0 forced me to upgrade from
JBoss
3.2.x to JBoss 4.x
- JBoss has its own copy of the xerces, xalan and
xml-apis
libraries. It was while poking around in the
manifest files
that I noticed that no one is yet supporting JAXP
1.3. The
versions do not appear to conflict with XOM.
- presently deploying my webapp as an expanded war
(i.e. as
a tree of directories like any other filesystem).
Because the libraries contained in JBoss were not supporting JAXP 1.3,
I went looking for a library that would meet my needs and found XOM.
The
fact that it was written by the same author that wrote my text book,
told
me I just had to give it a try. I'm attempting to use:
XOM 1.1a2
- needed XInclude, XMLSchema validation, and the
ability to
pass parameters to XSLT.
************************************************************************
Snippet from my XML document:
************************************************************************
<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?>
<jtt:apprentice_tasks
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:jtt="http://gov.jcsj2t.jtt30"
xsi:schemaLocation="http://gov.jcsj2t.jtt30
apprentice-schema.xsd">
The schema document (apprentice-schema.xsd) is located in the same
directory
as the instance document (though I am passing the instance document
to the
Builder as an InputStream).
************************************************************************
Snippet from my XMLSchema document:
************************************************************************
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://gov.jcsj2t.jtt30"
xmlns:jtt="http://gov.jcsj2t.jtt30"
elementFormDefault="qualified">
************************************************************************
Snippet from my Java Code:
************************************************************************
private Document parseDocument(InputStream datafileStream,
boolean validateDatafile,
boolean resolveXInclude)
throws XSLTransformerBeanParsingException {
Document document = null;
try {
XMLReader parser =
XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser"
);
parser.setFeature(
"http://apache.org/xml/features/validation/schema",
true
);
Builder builder = new Builder(parser, validateDatafile);
document = builder.build(datafileStream);
if (resolveXInclude) {
document = XIncluder.resolve(document);
}
} catch (ParsingException pe) {
int lineNumber = pe.getLineNumber();
int columnNumber = pe.getColumnNumber();
throw new XSLTransformerBeanParsingException(pe.getMessage() +
" See line number = " + lineNumber + ", column = " +
columnNumber);
}
************************************************************************
I did not see anyway to specify the schema to use in validation in the
XOM API so I am making the assumption that the Builder knows how to
locate the
appropriate XMLSchema document based upon the schemaLocation
attribute. (Though
this raises the question of how the Builder will function within a
war file
or other situation where the resources must be captured from
streams...).
Is the fact that the source XML document is an InputStream making a
difference
here?
Any help or references are greatly appreciated.
- Robert
-
[XOM-interest] Cannot find the declaration of element...,
Jacobs, Robert A., 03/09/2005
- Re: [XOM-interest] Cannot find the declaration of element..., Elliotte Harold, 03/09/2005
- Re: [XOM-interest] Cannot find the declaration of element..., Elliotte Harold, 03/09/2005
- <Possible follow-up(s)>
- RE: [XOM-interest] Cannot find the declaration of element..., Jacobs, Robert A., 03/09/2005
Archive powered by MHonArc 2.6.24.