All,
I am validating a xml document against schema using DOM parser. When I prefix the elements in instance document with namespace prefix I am getting
'cvc-elt.1 Cannot find the element xsi:ipos' error
when I remove the prefix xsi: from the XML instance I don't get this error. can anyone let me know why I see this behavior.
Below is the XML instance and the java program I used to validate the xml
<?xml version="1.0" ?>
<xsi:ipos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="substitute.xsd">
<xsi:ipo company_name="Petronet">
<xsi:open_date>1 March 2003</xsi:open_date>
<xsi:close_date>7 March 2003</xsi:close_date>
<xsi:rate>15</xsi:rate>
</xsi:ipo>
<xsi:ipo company_name="GAIL">
<xsi:open_date>1 March 2003</xsi:open_date>
<xsi:close_date>7 March 2003</xsi:close_date>
<xsi:rate>187</xsi:rate>
</xsi:ipo>
</xsi:ipos>
<xsi:ipos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="substitute.xsd">
<xsi:ipo company_name="Petronet">
<xsi:open_date>1 March 2003</xsi:open_date>
<xsi:close_date>7 March 2003</xsi:close_date>
<xsi:rate>15</xsi:rate>
</xsi:ipo>
<xsi:ipo company_name="GAIL">
<xsi:open_date>1 March 2003</xsi:open_date>
<xsi:close_date>7 March 2003</xsi:close_date>
<xsi:rate>187</xsi:rate>
</xsi:ipo>
</xsi:ipos>
Java code
=======
DOMParser dom = new DOMParser();
dom.setFeature("http://xml.org/sax/features/validation",true);
dom.setFeature("http://apache.org/xml/features/validation/schema",true);
dom.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
dom.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",args[1]);
dom.parse(args[0]);
dom.setFeature("http://xml.org/sax/features/validation",true);
dom.setFeature("http://apache.org/xml/features/validation/schema",true);
dom.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
dom.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",args[1]);
dom.parse(args[0]);
Regards
Purushotham
Do you Yahoo!?
Get better spam protection with Yahoo! Mail
