|
Re: Unresolved element when validate using DOM format [message #37214 is a reply to message #37111] |
Thu, 12 February 2004 14:32 |
Eclipse User |
|
|
|
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 |
Ed Merks Messages: 33217 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/
|
|
|
Powered by
FUDForum. Page generated in 0.04510 seconds