Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Daryl Butler   on Jul 09 In Java Category.

  
Question Answered By: Kawakib Mansour   on Jul 09

of course it is possible, 'cause these are basic needs in processing
XMLs.

1) for the first problem, you should first configure the Factory
instance( either DocumentBuilderFactory or SAXParserFactory ).

factory.setNamespaceAwar( true );
factory.setValidating( true );
// next method throws IllegalArgumentException
factory.setAttribute
( "java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema" ); //
for "XML schema  schema"

and then there is 2 ways for associating the schema(s):

I) With a schema declaration in the xml  document:
<documentRoot
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation='YourSchemaDefinition.xsd'
>

II) By specifying the schema(s) to use in the application.
factory.setAttribute
( "java.sun.com/xml/jaxp/properties/schemaSource",
new File( "YourSchemaDefinition.xsd"; ));

more information at:
java.sun.com/.../JAXPDOM9.html

2) for the second problem, if you're using DOM, you need to obtain
and modify the Text node.
And if you'r using SAX you should override appropriate method(s) of
registered ContentHandler to meet your needs.

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Does JAXP/XSLT support schema validation Or get search suggestion and latest updates.


Tagged: