Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Does JAXP/XSLT support schema validation

  Asked By: Daryl    Date: Jul 09    Category: Java    Views: 817
  

1. I have a java application that will be using XSLT, through the
JAXP
classes.
We would like to make sure that both the input and output XMLs are in
aggreement to 2 respective schemas. Is it possible to do this using
JAXP classes.

2. While doing the above conversion, we would like to extract some
values from the input XML to Java string. Similarly we would like to
insert some values contained within the Java variables to the
produced
XML. Is this possible at all.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Gerardo Morgan     Answered On: Jul 09

You can find everything you want here http://xml.apache.org/ dear
sony.
i'm sure it helps,just go fer it.

 
Answer #2    Answered By: Kawakib Mansour     Answered 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.

 
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: