Hi Mukul, It just doesn't work that way. Xerces has no business changing the value of "http://java.sun.com/xml/jaxp/properties/schemaSource". getProperty() must always return what the application set it to be (or null as the default) which isn't necessarily even a String (could be an InputStream, File, Object[], etc...). If you want to get the values of schema location hints in the document then you need to write a ContentHandler which does the work.
Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] "Mukul Gandhi" <[EMAIL PROTECTED]> wrote on 06/16/2008 12:12:45 PM: > Hi Michael, > Thanks for your reply and letting me know the correct property name. > > But I am still not able to achieve what I want to do. > > As per your suggestion I modified the Java program as below: > > [1] > parser.parse(new File(filename), this); > String schmLocation = (String) > parser.getProperty("http://java.sun.com/xml/jaxp/properties/schemaSource "); > System.out.println(schmLocation); > > But I get the output: > null > > (the exception now doesn't come) > > It seems, Xerces doesn't set this property by taking input from the > XML document's hint (i.e., xsi:noNamespaceSchemaLocation). > > But when I change the program to (and remove the hint, > xsi:noNamespaceSchemaLocation from the XML document): > > [1] > parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource ", > "schemaFileName.xsd"); > parser.parse(new File(filename), this); > String schmLocation = (String) > parser.getProperty("http://java.sun.com/xml/jaxp/properties/schemaSource "); > System.out.println(schmLocation); > > I get the output: > schemaFileName.xsd > > and the document also get's validated properly. > > But I need to achieve what is written in code fragment, [1]. i.e., I > want to supply the Schema file hint (i.e., > xsi:noNamespaceSchemaLocation) in the XML document, and retrieved the > Schema URI from the Java parsing program. > > Could you kindly suggest, how this can be achieved with Xerces. > > On Mon, Jun 16, 2008 at 9:14 PM, Michael Glavassevich > <[EMAIL PROTECTED]> wrote: > > Hi Mukul, > > > > The property name you're querying is incorrect. It should be > > "http://java.sun.com/xml/jaxp/properties/schemaSource" not > > "http://java.sun.com/xml/properties/jaxp/schemaSource". > > > > Thanks. > > > > Michael Glavassevich > > XML Parser Development > > IBM Toronto Lab > > E-mail: [EMAIL PROTECTED] > > E-mail: [EMAIL PROTECTED] > > > -- > Regards, > Mukul Gandhi > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]