Hi All,
Today I downloaded XercesJ 2.0.1 and implemented my application with it. I
have a problem with both the versions of XercesJ-2.0.0 and XercesJ-2.0.1.
Problem:
I am using XercesJ-2.0.0/XercesJ-2.0.1 (Implementing JAXP). I am using
DOM Parser to parse an xml instance validating against a schema and using
noNamespaceSchemaLocation. I have a fixed attribute in the schema. But
while parsing, the parser does not load the fixed attribute value into the
instance document.
(Note: With targetNameSpace and externalSchemaLocation property the parser
loads the fixed attribute.)
XML Instance Used:
<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://host/schemas/schema.xsd">
.......
.......
</request>
Schema Used:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pct="
http://host/location">
<xsd:import namespace="http://host/location" schemaLocation="
http://host/schemas/someSchema.xsd"/>
.....
...
<xsd:attribute name="name" type="xsd:string" fixed="SERVICE_NAME" />
...
....
</xsd:schema>
Code Used:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setIgnoringElementContentWhitespace(true);
factory.setValidating(true);
factory.setNamespaceAware(true);
factory.setAttribute("
http://java.sun.com/xml/jaxp/properties/schemaLanguage","
http://www.w3.org/2001/XMLSchema");
// I dont use the following property as it does not help for my
problem
// factory.setAttribute("
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation
", "schema.xsd");
DocumentBuilder parser = factory.newDocumentBuilder();
document = parser.parse(new InputSource((Reader)inputs));
Element root = doc.getDocumentElement();
NodeList nl = root.getChildNodes();
NamedNodeMap attrs = root.getAttributes();
String serviceName = "";
if (attrs.getNamedItem("name") != null) // Parser does not recognise
this fixed attribute from Schema
serviceName = attrs.getNamedItem("name").getFirstChild
().getNodeValue();
Is there any other property to be set? Or Is there any work around to this
problem? Or am I making any mistake here in my implementation?
Any suggestion is highly appreciated.
Thanks and regards.
Haladhar
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]