Discussion:
[saxon] how to use com.saxonica.validate package
panneer
2007-01-31 05:43:30 UTC
Permalink
hi,
I want to validate a XML document against a schema document.
I want to use com.saxonica.validate package.
Can anyone tell me how to use this package?
Also I want to know what are all the classes needs to be used?
Also I want some sample code about how to use the clases in this package?

Thanks
Panneer
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8723628
Sent from the saxon-help mailing list archive at Nabble.com.
James A. Robinson
2007-01-31 05:52:33 UTC
Permalink
Post by panneer
I want to validate a XML document against a schema document.
I want to use com.saxonica.validate package.
Can anyone tell me how to use this package?
Also I want to know what are all the classes needs to be used?
Also I want some sample code about how to use the clases in this package?
I'm assuming that you have access to Saxon-SA and that
you mean more than running the command line

java -jar /path/to/saxon8sa.jar com.saxonica.Validate foo.xml foo.xsd

Take a look at the documentation listed under

http://www.saxonica.com/documentation/schema-processing/intro.html

Specifically Dr. Kay lists a 'Controlling Validation from Java' under

http://www.saxonica.com/documentation/schema-processing/validation-api.html


Jim

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson ***@stanford.edu
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
panneer
2007-01-31 06:00:35 UTC
Permalink
I Understood the class com.saxonica.Validate class.
I dont want to use the command line utility.
But I want to use com.saxonica.validate package.
I want to use the classes available in these package only.
Please give some idea in these classes..

Thanks
Post by James A. Robinson
Post by panneer
I want to validate a XML document against a schema document.
I want to use com.saxonica.validate package.
Can anyone tell me how to use this package?
Also I want to know what are all the classes needs to be used?
Also I want some sample code about how to use the clases in this package?
I'm assuming that you have access to Saxon-SA and that
you mean more than running the command line
java -jar /path/to/saxon8sa.jar com.saxonica.Validate foo.xml foo.xsd
Take a look at the documentation listed under
http://www.saxonica.com/documentation/schema-processing/intro.html
Specifically Dr. Kay lists a 'Controlling Validation from Java' under
http://www.saxonica.com/documentation/schema-processing/validation-api.html
Jim
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8723756
Sent from the saxon-help mailing list archive at Nabble.com.
James A. Robinson
2007-01-31 06:47:53 UTC
Permalink
Post by panneer
I Understood the class com.saxonica.Validate class.
I dont want to use the command line utility.
But I want to use com.saxonica.validate package.
I want to use the classes available in these package only.
Please give some idea in these classes..
I'm really not sure what you mean by "use" -- do you mean more than
simply checking to see if something validates? Simply checking to see
if something validates is what I'd assume most people would want...

An example using the com.saxonica.validate classes to build my
own command line tool to take two arguments:

Path to W3C XML Schema
Path to .xml file

It calls the saxonica validation classes to see if the .xml validates
against the .xsd.

package org.highwire.jimr;

import java.io.File;
import java.io.IOException;

import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
import javax.xml.transform.stream.StreamSource;

import org.xml.sax.SAXException;
import com.saxonica.validate.*;

public class Validate {
public static void main(String args[]) {
try {
Validate.validate(new File(args[0]), new File(args[1]));
}
catch (SAXException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}

public static void validate(File schema, File target)
throws SAXException, IOException {
SchemaFactory factory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Validator validator = factory.newSchema(schema).newValidator();
validator.validate(new StreamSource(target));
}
}

Are you asking for more than this kind of example? Example of how
to set a special ErrorHandler, or use specific features???


Jim

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson ***@stanford.edu
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
Andrew Welch
2007-01-31 09:43:22 UTC
Permalink
Post by James A. Robinson
SchemaFactory factory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
If you specifically want to use Saxon for the validation then
apparently you are better off instantiating it explicitly:

SchemaFactory schemaFactory =
(SchemaFactory)Class.forName("com.saxonica.jaxp.SchemaFactoryImpl").newInstance();

I think this is the thread from an archive site - my work firewall
blocks it for some reason:

www.nabble.com/SchemaFactory.newInstance()-never-returns-Saxon-t3035491.html
panneer
2007-01-31 12:49:48 UTC
Permalink
I want to know how can I use com.saxonica.validate.SchemaAwareConfiguration
and
com.saxonica.validate.SchemaAwareConfiguration.SurrogateSchema classes.

Also tell me what is the use com.saxonica.validate package and its class.
Can I use those classes in my applications?

Thanks
Panneer
Post by Andrew Welch
Post by James A. Robinson
SchemaFactory factory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
If you specifically want to use Saxon for the validation then
SchemaFactory schemaFactory =
(SchemaFactory)Class.forName("com.saxonica.jaxp.SchemaFactoryImpl").newInstance();
I think this is the thread from an archive site - my work firewall
www.nabble.com/SchemaFactory.newInstance()-never-returns-Saxon-t3035491.html
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8728362
Sent from the saxon-help mailing list archive at Nabble.com.
panneer
2007-01-31 12:55:24 UTC
Permalink
Thanks for your reply and example.

I want more example about how can I write special ErrorHandler and some
other special features.
I want to use startElement and endElement method also for parsing the xml
document.

Thanks
Panneer Selvam
Post by James A. Robinson
Post by panneer
I Understood the class com.saxonica.Validate class.
I dont want to use the command line utility.
But I want to use com.saxonica.validate package.
I want to use the classes available in these package only.
Please give some idea in these classes..
I'm really not sure what you mean by "use" -- do you mean more than
simply checking to see if something validates? Simply checking to see
if something validates is what I'd assume most people would want...
An example using the com.saxonica.validate classes to build my
Path to W3C XML Schema
Path to .xml file
It calls the saxonica validation classes to see if the .xml validates
against the .xsd.
package org.highwire.jimr;
import java.io.File;
import java.io.IOException;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
import javax.xml.transform.stream.StreamSource;
import org.xml.sax.SAXException;
import com.saxonica.validate.*;
public class Validate {
public static void main(String args[]) {
try {
Validate.validate(new File(args[0]), new File(args[1]));
}
catch (SAXException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
public static void validate(File schema, File target)
throws SAXException, IOException {
SchemaFactory factory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Validator validator = factory.newSchema(schema).newValidator();
validator.validate(new StreamSource(target));
}
}
Are you asking for more than this kind of example? Example of how
to set a special ErrorHandler, or use specific features???
Jim
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Stanford University HighWire Press http://highwire.stanford.edu/
+1 650 7237294 (Work) +1 650 7259335 (Fax)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8728457
Sent from the saxon-help mailing list archive at Nabble.com.
Michael Kay
2007-01-31 13:32:28 UTC
Permalink
Post by panneer
I want to know how can I use
com.saxonica.validate.SchemaAwareConfiguration
and
com.saxonica.validate.SchemaAwareConfiguration.SurrogateSchema
classes.
Also tell me what is the use com.saxonica.validate package
and its class.
Can I use those classes in my applications?
Rather than asking how you can use a particular class, it would be more
useful to explain what you want to achieve (what problem are you trying to
solve). These classes may or may not be part of the solution. Other users
have already responded to you explaining how to validate an instance
document against a schema. Is that what you are trying to do, or are you
trying to do something else?

Michael Kay
http://www.saxonica.com/
panneer
2007-02-01 05:39:13 UTC
Permalink
Hi,
I will explain what I want to achieve..

I have many XML documents and One schema document.
I want to validate all the xml documents against the schema document.
Also I want to know whether I can use the classes in the
com.saxonica.validate package
Also I know there is a commande line utility provided by the saxonica
(com.saxonica.Validate class).
I just want to know is there any way that I can validate the xml documents
other than using command line utility.

Thanks
Panneer
Post by Michael Kay
Post by panneer
I want to know how can I use
com.saxonica.validate.SchemaAwareConfiguration
and
com.saxonica.validate.SchemaAwareConfiguration.SurrogateSchema classes.
Also tell me what is the use com.saxonica.validate package
and its class.
Can I use those classes in my applications?
Rather than asking how you can use a particular class, it would be more
useful to explain what you want to achieve (what problem are you trying to
solve). These classes may or may not be part of the solution. Other users
have already responded to you explaining how to validate an instance
document against a schema. Is that what you are trying to do, or are you
trying to do something else?
Michael Kay
http://www.saxonica.com/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8743342
Sent from the saxon-help mailing list archive at Nabble.com.
Andrew Welch
2007-02-01 09:39:35 UTC
Permalink
Post by panneer
Hi,
I will explain what I want to achieve..
I have many XML documents and One schema document.
I want to validate all the xml documents against the schema document.
Also I want to know whether I can use the classes in the
com.saxonica.validate package
Also I know there is a commande line utility provided by the saxonica
(com.saxonica.Validate class).
I just want to know is there any way that I can validate the xml documents
other than using command line utility.
You can use Kernow to do directory validation, although there's a
"bug" in the 1.4 release in that it won't allow you to use Saxon
(which has been covered in other threads) so it defaults back to
Xerces... which is much slower and less help helpful with its
messages, eg no line numbers.

Kernow's open source and it's easy enough to make the changes if you
feel like doing it yourself, or if you're not worried about the GUI
then just roll your own. It's well in need of an update now, but I'm
on other things at the moment, so it will have to wait.
Michael Kay
2007-01-31 13:44:00 UTC
Permalink
Post by panneer
I want to use startElement and endElement method also for
parsing the xml document.
Again, you're not explaining what you want to do, or what problems you are
having. This is like saying you want to use a rubber band to mend your car.
It might (or might not) be a sensible thing to do, but we can't help you
with it unless we know a lot more about your problem.

Michael Kay
http://www.saxonica.com/
Michael Kay
2007-02-01 09:41:00 UTC
Permalink
Post by panneer
I will explain what I want to achieve..
I have many XML documents and One schema document.
I want to validate all the xml documents against the schema document.
You can do this entirely using JAXP interfaces. Take a look at
SchemaValidatorHandlerExample.java in the samples directory (sample
applications are in the saxon-resources download package, available both on
the SourceForge site and on the www.saxonica.com download page). The essence
of the code is this:

SchemaFactory schemaFactory;

// Set a system property to force selection of the Saxon
SchemaFactory implementation
// This is commented out because it shouldn't be necessary if
Saxon-SA is on the classpath;
// but in the event of configuration problems, try reinstating
it.

//
System.setProperty("javax.xml.validation.SchemaFactory:http://www.w3.org/200
1/XMLSchema",
// "com.saxonica.schema.SchemaFactoryImpl");

schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
System.err.println("Loaded schema validation provider " +
schemaFactory.getClass().getName());

schemaFactory.setErrorHandler(new LocalErrorHandler());
//create a grammar object.
Schema schemaGrammar;

if (args[0].equals("--")) {
// in this case, the schema must be identified using
xsi:schemaLocation
schemaGrammar = schemaFactory.newSchema();
} else {
schemaGrammar = schemaFactory.newSchema(new File(args[0]));
System.err.println("Created Grammar object for schema :
"+args[0]);
}

Resolver resolver = new Resolver();

//create a validator to validate against the schema.
ValidatorHandler schemaValidator =
schemaGrammar.newValidatorHandler();
schemaValidator.setResourceResolver(resolver);
schemaValidator.setErrorHandler(new LocalErrorHandler());
schemaValidator.setContentHandler(new
LocalContentHandler(schemaValidator.getTypeInfoProvider()));

System.err.println("Validating "+args[1] +" against grammar
"+args[0]);
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
SAXParser parser = parserFactory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.setContentHandler(schemaValidator);
reader.parse(new InputSource(new
File(args[1]).toURI().toString()));

System.err.println("Validation successful");
} catch (SAXException saxe) {
exit(1, "Error: " + saxe.getMessage());
} catch (Exception e) {
e.printStackTrace();
exit(2, "Fatal Error: " + e);
}
}

The general structure is that it first loads the schema, then validates the
instance document. To validate multiple instance documents, just put the
validation code in a loop. The simplest change would be to create a new
ValidationHandler and SAXParser/XMLReader for each input document, though
you can probably reuse these objects if you need to.
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
When you run the above code, you are using these classes implicitly, but via
a standard interface defined in JAXP. You can use the implementation classes
directly if you want, but you don't need to unless you need greater control.
Post by panneer
I just want to know is there any way that I can validate the
xml documents other than using command line utility.
Yes, see above.

Michael Kay
http://www.saxonica.com
panneer
2007-02-01 10:10:35 UTC
Permalink
Thank you very much for your response..

You are telling me to use JAXP for the validation. thats fine.
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
When you run the above code, you are using these classes implicitly, but via
a standard interface defined in JAXP. You can use the implementation classes
directly if you want, but you don't need to unless you need greater control.
Can I use these implmentation class directly,I may need greater control on
validation.
So please tell me how can use the classes?
I see many classes inside com.saxonica.validate package.
like AllElementValidator, AnyTypeValidator, AttributeValidator and....
ValidationStack, XSIAttributeHandler.

How can I use these classes? What is the use of all these classes?

There is a line at the bottom in the package description saying that "None
of the classes in this package will normally be used directly by user
applications."

What is the meaning for the above comment?

Why I am so interest in this package is "My project Leader asked me to use
this package only to validate the XML documents"

If this way is not possible then I can tell my leader the proper reason..

Please advice me in this..

Thanks
Panneer
Post by panneer
Post by panneer
I will explain what I want to achieve..
I have many XML documents and One schema document.
I want to validate all the xml documents against the schema document.
You can do this entirely using JAXP interfaces. Take a look at
SchemaValidatorHandlerExample.java in the samples directory (sample
applications are in the saxon-resources download package, available both on
the SourceForge site and on the www.saxonica.com download page). The essence
SchemaFactory schemaFactory;
// Set a system property to force selection of the Saxon
SchemaFactory implementation
// This is commented out because it shouldn't be necessary if
Saxon-SA is on the classpath;
// but in the event of configuration problems, try reinstating
it.
//
System.setProperty("javax.xml.validation.SchemaFactory:http://www.w3.org/200
1/XMLSchema",
// "com.saxonica.schema.SchemaFactoryImpl");
schemaFactory =
SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
System.err.println("Loaded schema validation provider " +
schemaFactory.getClass().getName());
schemaFactory.setErrorHandler(new LocalErrorHandler());
//create a grammar object.
Schema schemaGrammar;
if (args[0].equals("--")) {
// in this case, the schema must be identified using
xsi:schemaLocation
schemaGrammar = schemaFactory.newSchema();
} else {
schemaGrammar = schemaFactory.newSchema(new
File(args[0]));
"+args[0]);
}
Resolver resolver = new Resolver();
//create a validator to validate against the schema.
ValidatorHandler schemaValidator =
schemaGrammar.newValidatorHandler();
schemaValidator.setResourceResolver(resolver);
schemaValidator.setErrorHandler(new LocalErrorHandler());
schemaValidator.setContentHandler(new
LocalContentHandler(schemaValidator.getTypeInfoProvider()));
System.err.println("Validating "+args[1] +" against grammar
"+args[0]);
SAXParserFactory parserFactory =
SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
SAXParser parser = parserFactory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.setContentHandler(schemaValidator);
reader.parse(new InputSource(new
File(args[1]).toURI().toString()));
System.err.println("Validation successful");
} catch (SAXException saxe) {
exit(1, "Error: " + saxe.getMessage());
} catch (Exception e) {
e.printStackTrace();
exit(2, "Fatal Error: " + e);
}
}
The general structure is that it first loads the schema, then validates the
instance document. To validate multiple instance documents, just put the
validation code in a loop. The simplest change would be to create a new
ValidationHandler and SAXParser/XMLReader for each input document, though
you can probably reuse these objects if you need to.
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
When you run the above code, you are using these classes implicitly, but via
a standard interface defined in JAXP. You can use the implementation classes
directly if you want, but you don't need to unless you need greater control.
Post by panneer
I just want to know is there any way that I can validate the
xml documents other than using command line utility.
Yes, see above.
Michael Kay
http://www.saxonica.com
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8745772
Sent from the saxon-help mailing list archive at Nabble.com.
Andrew Welch
2007-02-01 10:19:03 UTC
Permalink
Post by panneer
Can I use these implmentation class directly,I may need greater control on
validation.
Why? If you explain your problem you *may* not need to use those classes...
Post by panneer
So please tell me how can use the classes?
I see many classes inside com.saxonica.validate package.
like AllElementValidator, AnyTypeValidator, AttributeValidator and....
ValidationStack, XSIAttributeHandler.
How can I use these classes? What is the use of all these classes?
There is a line at the bottom in the package description saying that "None
of the classes in this package will normally be used directly by user
applications."
What is the meaning for the above comment?
Because normal user applications will use the JAXP interfaces.
Post by panneer
Why I am so interest in this package is "My project Leader asked me to use
this package only to validate the XML documents"
Ok, thats fine.
Post by panneer
If this way is not possible then I can tell my leader the proper reason..
Yes, you can validate XML documents using Saxon using the
com.saxonica.Validate entry point from the command line, or through
the standard JAXP interfaces in Java... give it a go, its very
straightforward.

cheers
andrew
Michael Kay
2007-02-01 11:01:34 UTC
Permalink
Post by panneer
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
Can I use these implmentation class directly,I may need
greater control on validation.
So please tell me how can use the classes?
I see many classes inside com.saxonica.validate package.
like AllElementValidator, AnyTypeValidator, AttributeValidator and....
ValidationStack, XSIAttributeHandler.
How can I use these classes? What is the use of all these classes?
These classes implement the internal machinery to perform the various
aspects of schema validation. In general the validation process operates as
a pipeline; events such as startElement and endElement are passed down the
pipeline through the various validation filters. In principle you can
assemble a custom pipeline to do validation in a particular way, or you
could add additional validation components to the pipeline. In XSLT, for
example, there is a rule that identity constraints are not checked when
validation starts at an element node rather than a document node, so XSLT
assembles a validation pipeline in which the identity constraint checker is
omitted. It would similarly be possible, at least in principle, to add extra
steps to the pipeline that invoke user-written Java code to do extra
algorithmic checking of element and attribute content, or even to implement
co-constraints.

This is very advanced usage and I think it is very unlikely that you need
this kind of capability; if you do need it you will need a very deep
understanding of the schema specification. If you're operating at this
level, it's like buying a standard Ford from your local dealer and
converting it to a stretch limo. It can be done, but it requires significant
engineering knowledge. Stick to the JAXP interface until you have a proven
need to go beyond it.

Michael Kay
http://www.saxonica.com/
panneer
2007-02-01 12:58:47 UTC
Permalink
Thank you very much, your reply was really helpful..

Now I have decided to use JAXP API...
I see there is a package called "com.saxonica.jaxp"

Can I use this package for my validation?
But the sample program "SchemaValidatorHandlerExample.java" did not use this
package?

Can I have any sample program that uses com.saxonica.jaxp package?

Becouse I want to know how I can use these package classes for my
requirement.

Please advice me

Thanks
Panneer
Post by Michael Kay
Post by panneer
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
Can I use these implmentation class directly,I may need
greater control on validation.
So please tell me how can use the classes?
I see many classes inside com.saxonica.validate package.
like AllElementValidator, AnyTypeValidator, AttributeValidator and....
ValidationStack, XSIAttributeHandler.
How can I use these classes? What is the use of all these classes?
These classes implement the internal machinery to perform the various
aspects of schema validation. In general the validation process operates as
a pipeline; events such as startElement and endElement are passed down the
pipeline through the various validation filters. In principle you can
assemble a custom pipeline to do validation in a particular way, or you
could add additional validation components to the pipeline. In XSLT, for
example, there is a rule that identity constraints are not checked when
validation starts at an element node rather than a document node, so XSLT
assembles a validation pipeline in which the identity constraint checker is
omitted. It would similarly be possible, at least in principle, to add extra
steps to the pipeline that invoke user-written Java code to do extra
algorithmic checking of element and attribute content, or even to implement
co-constraints.
This is very advanced usage and I think it is very unlikely that you need
this kind of capability; if you do need it you will need a very deep
understanding of the schema specification. If you're operating at this
level, it's like buying a standard Ford from your local dealer and
converting it to a stretch limo. It can be done, but it requires significant
engineering knowledge. Stick to the JAXP interface until you have a proven
need to go beyond it.
Michael Kay
http://www.saxonica.com/
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8747711
Sent from the saxon-help mailing list archive at Nabble.com.
Michael Kay
2007-02-01 13:18:57 UTC
Permalink
JAXP defines a factory class, SchemaFactory. If you set up your
configuration correctly then when you call SchemaFactory.newInstance(), the
class it returns will be an instance of com.saxonica.jaxp.SchemaFactoryImpl.
The idea, though, is that you don't need to refer this class explicitly in
your application, because you can then make your application work with any
JAXP implementation. However, if you want to write an application that will
only run with Saxon, then it's more reliable and more efficient to
instantiate com.saxonica.jaxp.SchemaFactoryImpl directly using its
constructor, rather than using SchemaFactory.newInstance().

One advantage of using the direct constructor is that you can then supply an
instance of SchemaAwareConfiguration, which allows this SchemaFactory to
share the same configuration as other SchemaFactory instances or other Saxon
processes such as document building, transformation, and query.

Michael Kay
http://www.saxonica.com/
-----Original Message-----
Sent: 01 February 2007 12:59
Subject: Re: [saxon] how to use com.saxonica.validate package
Thank you very much, your reply was really helpful..
Now I have decided to use JAXP API...
I see there is a package called "com.saxonica.jaxp"
Can I use this package for my validation?
But the sample program "SchemaValidatorHandlerExample.java"
did not use this package?
Can I have any sample program that uses com.saxonica.jaxp package?
Becouse I want to know how I can use these package classes
for my requirement.
Please advice me
Thanks
Panneer
Post by Michael Kay
Post by panneer
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
Can I use these implmentation class directly,I may need greater
control on validation.
So please tell me how can use the classes?
I see many classes inside com.saxonica.validate package.
like AllElementValidator, AnyTypeValidator,
AttributeValidator and....
Post by Michael Kay
Post by panneer
ValidationStack, XSIAttributeHandler.
How can I use these classes? What is the use of all these classes?
These classes implement the internal machinery to perform
the various
Post by Michael Kay
aspects of schema validation. In general the validation process
operates as a pipeline; events such as startElement and
endElement are
Post by Michael Kay
passed down the pipeline through the various validation filters. In
principle you can assemble a custom pipeline to do validation in a
particular way, or you could add additional validation
components to
Post by Michael Kay
the pipeline. In XSLT, for example, there is a rule that identity
constraints are not checked when validation starts at an
element node
Post by Michael Kay
rather than a document node, so XSLT assembles a validation
pipeline
Post by Michael Kay
in which the identity constraint checker is omitted. It would
similarly be possible, at least in principle, to add extra steps to
the pipeline that invoke user-written Java code to do extra
algorithmic checking of element and attribute content, or even to
implement co-constraints.
This is very advanced usage and I think it is very unlikely
that you
Post by Michael Kay
need this kind of capability; if you do need it you will
need a very
Post by Michael Kay
deep understanding of the schema specification. If you're
operating at
Post by Michael Kay
this level, it's like buying a standard Ford from your local dealer
and converting it to a stretch limo. It can be done, but it
requires
Post by Michael Kay
significant engineering knowledge. Stick to the JAXP
interface until
Post by Michael Kay
you have a proven need to go beyond it.
Michael Kay
http://www.saxonica.com/
----------------------------------------------------------------------
Post by Michael Kay
--- Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to
make your job
Post by Michael Kay
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache
Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=1216
Post by Michael Kay
42 _______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
http://www.nabble.com/how-to-use-com.saxonica.validate-package
-tf3146814.html#a8747711
Sent from the saxon-help mailing list archive at Nabble.com.
--------------------------------------------------------------
-----------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to make
your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&
dat=121642
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
panneer
2007-02-02 06:37:34 UTC
Permalink
Hi Thank you very much, I understood the JAXP..

Also I want to know more about com.saxonica.Validate class..
I want to write my own validation class which should use Validate class

How can I use the Validate class methods..?

Also I see that com.saxonica.Validate classes methods are not public..
So how can I call this Validate class methods from my class.

Which are all the methods I should use from my class.

Please help me out in this..

Thanks
Panneer
Post by Michael Kay
JAXP defines a factory class, SchemaFactory. If you set up your
configuration correctly then when you call SchemaFactory.newInstance(), the
class it returns will be an instance of
com.saxonica.jaxp.SchemaFactoryImpl.
The idea, though, is that you don't need to refer this class explicitly in
your application, because you can then make your application work with any
JAXP implementation. However, if you want to write an application that will
only run with Saxon, then it's more reliable and more efficient to
instantiate com.saxonica.jaxp.SchemaFactoryImpl directly using its
constructor, rather than using SchemaFactory.newInstance().
One advantage of using the direct constructor is that you can then supply an
instance of SchemaAwareConfiguration, which allows this SchemaFactory to
share the same configuration as other SchemaFactory instances or other Saxon
processes such as document building, transformation, and query.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
Sent: 01 February 2007 12:59
Subject: Re: [saxon] how to use com.saxonica.validate package
Thank you very much, your reply was really helpful..
Now I have decided to use JAXP API...
I see there is a package called "com.saxonica.jaxp"
Can I use this package for my validation?
But the sample program "SchemaValidatorHandlerExample.java"
did not use this package?
Can I have any sample program that uses com.saxonica.jaxp package?
Becouse I want to know how I can use these package classes
for my requirement.
Please advice me
Thanks
Panneer
Post by Michael Kay
Post by panneer
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
Can I use these implmentation class directly,I may need greater
control on validation.
So please tell me how can use the classes?
I see many classes inside com.saxonica.validate package.
like AllElementValidator, AnyTypeValidator,
AttributeValidator and....
Post by Michael Kay
Post by panneer
ValidationStack, XSIAttributeHandler.
How can I use these classes? What is the use of all these classes?
These classes implement the internal machinery to perform
the various
Post by Michael Kay
aspects of schema validation. In general the validation process
operates as a pipeline; events such as startElement and
endElement are
Post by Michael Kay
passed down the pipeline through the various validation filters. In
principle you can assemble a custom pipeline to do validation in a
particular way, or you could add additional validation
components to
Post by Michael Kay
the pipeline. In XSLT, for example, there is a rule that identity
constraints are not checked when validation starts at an
element node
Post by Michael Kay
rather than a document node, so XSLT assembles a validation
pipeline
Post by Michael Kay
in which the identity constraint checker is omitted. It would
similarly be possible, at least in principle, to add extra steps to
the pipeline that invoke user-written Java code to do extra
algorithmic checking of element and attribute content, or even to
implement co-constraints.
This is very advanced usage and I think it is very unlikely
that you
Post by Michael Kay
need this kind of capability; if you do need it you will
need a very
Post by Michael Kay
deep understanding of the schema specification. If you're
operating at
Post by Michael Kay
this level, it's like buying a standard Ford from your local dealer
and converting it to a stretch limo. It can be done, but it
requires
Post by Michael Kay
significant engineering knowledge. Stick to the JAXP
interface until
Post by Michael Kay
you have a proven need to go beyond it.
Michael Kay
http://www.saxonica.com/
----------------------------------------------------------------------
Post by Michael Kay
--- Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to
make your job
Post by Michael Kay
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=1216
Post by Michael Kay
42 _______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
http://www.nabble.com/how-to-use-com.saxonica.validate-package
-tf3146814.html#a8747711
Sent from the saxon-help mailing list archive at Nabble.com.
--------------------------------------------------------------
-----------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to make
your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&
dat=121642
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8762465
Sent from the saxon-help mailing list archive at Nabble.com.
panneer
2007-02-02 08:00:38 UTC
Permalink
Hi One more question..

Can you also explain about loadDocument method of Validate class?

What should be the third argument(Configuration) to this method?
How we can get the Configuration object?

Please give me some sample code to use this loadDocument method?

Thanks
Panneer
Post by Michael Kay
JAXP defines a factory class, SchemaFactory. If you set up your
configuration correctly then when you call SchemaFactory.newInstance(), the
class it returns will be an instance of
com.saxonica.jaxp.SchemaFactoryImpl.
The idea, though, is that you don't need to refer this class explicitly in
your application, because you can then make your application work with any
JAXP implementation. However, if you want to write an application that will
only run with Saxon, then it's more reliable and more efficient to
instantiate com.saxonica.jaxp.SchemaFactoryImpl directly using its
constructor, rather than using SchemaFactory.newInstance().
One advantage of using the direct constructor is that you can then supply an
instance of SchemaAwareConfiguration, which allows this SchemaFactory to
share the same configuration as other SchemaFactory instances or other Saxon
processes such as document building, transformation, and query.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
Sent: 01 February 2007 12:59
Subject: Re: [saxon] how to use com.saxonica.validate package
Thank you very much, your reply was really helpful..
Now I have decided to use JAXP API...
I see there is a package called "com.saxonica.jaxp"
Can I use this package for my validation?
But the sample program "SchemaValidatorHandlerExample.java"
did not use this package?
Can I have any sample program that uses com.saxonica.jaxp package?
Becouse I want to know how I can use these package classes
for my requirement.
Please advice me
Thanks
Panneer
Post by Michael Kay
Post by panneer
Post by panneer
Also I want to know whether I can use the classes in the
com.saxonica.validate package.
Can I use these implmentation class directly,I may need greater
control on validation.
So please tell me how can use the classes?
I see many classes inside com.saxonica.validate package.
like AllElementValidator, AnyTypeValidator,
AttributeValidator and....
Post by Michael Kay
Post by panneer
ValidationStack, XSIAttributeHandler.
How can I use these classes? What is the use of all these classes?
These classes implement the internal machinery to perform
the various
Post by Michael Kay
aspects of schema validation. In general the validation process
operates as a pipeline; events such as startElement and
endElement are
Post by Michael Kay
passed down the pipeline through the various validation filters. In
principle you can assemble a custom pipeline to do validation in a
particular way, or you could add additional validation
components to
Post by Michael Kay
the pipeline. In XSLT, for example, there is a rule that identity
constraints are not checked when validation starts at an
element node
Post by Michael Kay
rather than a document node, so XSLT assembles a validation
pipeline
Post by Michael Kay
in which the identity constraint checker is omitted. It would
similarly be possible, at least in principle, to add extra steps to
the pipeline that invoke user-written Java code to do extra
algorithmic checking of element and attribute content, or even to
implement co-constraints.
This is very advanced usage and I think it is very unlikely
that you
Post by Michael Kay
need this kind of capability; if you do need it you will
need a very
Post by Michael Kay
deep understanding of the schema specification. If you're
operating at
Post by Michael Kay
this level, it's like buying a standard Ford from your local dealer
and converting it to a stretch limo. It can be done, but it
requires
Post by Michael Kay
significant engineering knowledge. Stick to the JAXP
interface until
Post by Michael Kay
you have a proven need to go beyond it.
Michael Kay
http://www.saxonica.com/
----------------------------------------------------------------------
Post by Michael Kay
--- Using Tomcat but need to do more? Need to support web services,
security?
Get stuff done quickly with pre-integrated technology to
make your job
Post by Michael Kay
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=1216
Post by Michael Kay
42 _______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
http://www.nabble.com/how-to-use-com.saxonica.validate-package
-tf3146814.html#a8747711
Sent from the saxon-help mailing list archive at Nabble.com.
--------------------------------------------------------------
-----------
Using Tomcat but need to do more? Need to support web
services, security?
Get stuff done quickly with pre-integrated technology to make
your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on
Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&
dat=121642
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job
easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
saxon-help mailing list
https://lists.sourceforge.net/lists/listinfo/saxon-help
--
View this message in context: http://www.nabble.com/how-to-use-com.saxonica.validate-package-tf3146814.html#a8763079
Sent from the saxon-help mailing list archive at Nabble.com.
Loading...