problem using prefix in xml instance document 2004-02-26 - By purushotham
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> 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]); Regards Purushotham
--------------------------------- Do you Yahoo!? Get better spam protection with Yahoo! Mail <DIV> <DIV>All, </DIV> <DIV> </DIV> <DIV>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 < /DIV> <DIV>'cvc-elt.1 Cannot find the element xsi:ipos' error</DIV> <DIV> </DIV> <DIV>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.</DIV> <DIV> </DIV> <DIV>Below is the XML instance and the java program I used to validate the xml< /DIV> <DIV> </DIV> <DIV><?xml version="1.0" ?><BR><xsi:ipos xmlns:xsi="<A href="http:/ /www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance< /A>" xsi:noNamespaceSchemaLocation="substitute.xsd"><BR> <xsi:ipo company_name="Petronet"><BR> <xsi:open_date>1 March 2003 </xsi:open_date><BR> <xsi:close_date>7 March 2003< /xsi:close_date><BR> <xsi:rate>15</xsi:rate><BR>  ;</xsi:ipo><BR> <xsi:ipo company_name="GAIL"><BR> <xsi:open_date>1 March 2003</xsi:open_date><BR> <xsi :close_date>7 March 2003</xsi:close_date><BR> <xsi:rate >187</xsi:rate><BR> </xsi:ipo><BR></xsi:ipos></DIV> <DIV> </DIV> <DIV> </DIV> <DIV>Java code</DIV> <DIV>=======</DIV> <DIV> </DIV> <DIV> DOMParser dom = new DOMParser();<BR> dom.setFeature ("<A href='http://xml.org/sax/features/validation",true'>http://xml.org/sax /features/validation",true</A>);<BR> dom.setFeature("<A href='http:/ /apache.org/xml/features/validation/schema",true'>http://apache.org/xml/features /validation/schema",true</A>);<BR> dom.setFeature("<A href='http:/ /apache.org/xml/features/validation/schema-full-checking",true'>http://apache .org/xml/features/validation/schema-full-checking",true</A>);<BR> dom.setProperty("<A href='http://apache.org/xml /properties/schema/external-noNamespaceSchemaLocation",args[1'>http://apache.org /xml/properties/schema/external-noNamespaceSchemaLocation",args[1</A>]);<BR> dom.parse(args[0]);</DIV> <DIV> </DIV> <DIV> </DIV> <DIV>Regards</DIV> <DIV>Purushotham</DIV> <DIV> </DIV></DIV><p><hr SIZE=1> Do you Yahoo!?<br> Get better spam protection with <a href="http://us.rd.yahoo.com/mailtag_us/ *http://antispam.yahoo.com/tools">Yahoo! Mail</a>
|
|