Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Unresolved element when validate using DOM format
Unresolved element when validate using DOM format [message #37111] Wed, 11 February 2004 23:09 Go to next message
Joshua Hui is currently offline Joshua HuiFriend
Messages: 23
Registered: July 2009
Junior Member
Hi,

When I parsed the xsd file as DOM and set it to XSDSchema for validation,
it
gave me the following error.

At node [xsd:element], XSD: Element Reference 'http://xyz.com#properties'
is unresolved

However, if I parsed the xsd file directly, it works fine. Any idea?

Here is the XSD file. The properties element does exist in the "xyz.xsd"
schema file in the given location.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:cm="http://xyz.com"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://xyz.com"
schemaLocation="file:///c:/tmp/xyz.xsd" />
<xsd:element name="Simple30">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="0" ref="cm:properties"/>
</xsd:sequence>
<xsd:attribute name="varchar200" use="optional" default="Hello">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:maxLength value="200" />
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>

Here is how I validate the schema.

Element schemaElem = xsdDOMObject.getDocumentElement();

if (schemaElem.getLocalName().equals("schema")
&&
XSDConstants.isSchemaForSchemaNamespace(schemaElem.getNamesp aceURI())) {

xsdSchema = xsdFactory.createXSDSchema();
xsdSchema.setElement(schemaElem);
xsdSchema.validate();

// Check the result of parsing schema
checkDiagnostics(xsdSchema);
} else {
// Throw an exception
}

Thanks.

Joshua
Re: Unresolved element when validate using DOM format [message #37214 is a reply to message #37111] Thu, 12 February 2004 14:32 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Joshua,

Unless your schema is in a resource in a resource set, it won't be able to
demand load any imported or included schemas, i.e., all external references
will fail to resolve.


Joshua Hui wrote:

> Hi,
>
> When I parsed the xsd file as DOM and set it to XSDSchema for validation,
> it
> gave me the following error.
>
> At node [xsd:element], XSD: Element Reference 'http://xyz.com#properties'
> is unresolved
>
> However, if I parsed the xsd file directly, it works fine. Any idea?
>
> Here is the XSD file. The properties element does exist in the "xyz.xsd"
> schema file in the given location.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:cm="http://xyz.com"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:import namespace="http://xyz.com"
> schemaLocation="file:///c:/tmp/xyz.xsd" />
> <xsd:element name="Simple30">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element maxOccurs="1" minOccurs="0" ref="cm:properties"/>
> </xsd:sequence>
> <xsd:attribute name="varchar200" use="optional" default="Hello">
> <xsd:simpleType>
> <xsd:restriction base="xsd:string">
> <xsd:maxLength value="200" />
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:attribute>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> Here is how I validate the schema.
>
> Element schemaElem = xsdDOMObject.getDocumentElement();
>
> if (schemaElem.getLocalName().equals("schema")
> &&
> XSDConstants.isSchemaForSchemaNamespace(schemaElem.getNamesp aceURI())) {
>
> xsdSchema = xsdFactory.createXSDSchema();
> xsdSchema.setElement(schemaElem);
> xsdSchema.validate();
>
> // Check the result of parsing schema
> checkDiagnostics(xsdSchema);
> } else {
> // Throw an exception
> }
>
> Thanks.
>
> Joshua
Re: Unresolved element when validate using DOM format [message #583445 is a reply to message #37111] Thu, 12 February 2004 14:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Joshua,

Unless your schema is in a resource in a resource set, it won't be able to
demand load any imported or included schemas, i.e., all external references
will fail to resolve.


Joshua Hui wrote:

> Hi,
>
> When I parsed the xsd file as DOM and set it to XSDSchema for validation,
> it
> gave me the following error.
>
> At node [xsd:element], XSD: Element Reference 'http://xyz.com#properties'
> is unresolved
>
> However, if I parsed the xsd file directly, it works fine. Any idea?
>
> Here is the XSD file. The properties element does exist in the "xyz.xsd"
> schema file in the given location.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:cm="http://xyz.com"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <xsd:import namespace="http://xyz.com"
> schemaLocation="file:///c:/tmp/xyz.xsd" />
> <xsd:element name="Simple30">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element maxOccurs="1" minOccurs="0" ref="cm:properties"/>
> </xsd:sequence>
> <xsd:attribute name="varchar200" use="optional" default="Hello">
> <xsd:simpleType>
> <xsd:restriction base="xsd:string">
> <xsd:maxLength value="200" />
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:attribute>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> Here is how I validate the schema.
>
> Element schemaElem = xsdDOMObject.getDocumentElement();
>
> if (schemaElem.getLocalName().equals("schema")
> &&
> XSDConstants.isSchemaForSchemaNamespace(schemaElem.getNamesp aceURI())) {
>
> xsdSchema = xsdFactory.createXSDSchema();
> xsdSchema.setElement(schemaElem);
> xsdSchema.validate();
>
> // Check the result of parsing schema
> checkDiagnostics(xsdSchema);
> } else {
> // Throw an exception
> }
>
> Thanks.
>
> Joshua


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:xsd location and import problem
Next Topic:How to provide a different schema content
Goto Forum:
  


Current Time: Tue Mar 19 05:19:43 GMT 2024

Powered by FUDForum. Page generated in 0.02863 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top