XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Catalog Resolver for XSD and XSLT

Hi,

What is the canonical way to validate XML files (loaded using
JAXP/DOM) against an XSD then subsequently transform them using an XSL
template having file paths determined from a catalog resolver? See
this SO question for details:
http://stackoverflow.com/q/25698764/59087

The posted answer works (http://stackoverflow.com/a/25698765/59087),
but has undesirable traits, such as:

* Using an XMLCatalogResolver and a CatalogResolver.
* Creating an XML catalog resolver instance using the catalog resolver instance.
* Traversing a DOM to determine the XSD URI.
* Creating a SchemaFactory to perform the validation.
* Calling the XML catalog resolver instance to find the local XSD file path.
* Passing the catalog resolver instance to the XSL transformer instance.

It seems like those aspects of the code should be handled by existing
APIs, especially the contortions required to extract the XSD URI from
the DOM. Contortions such as parsing processing instruction attributes
or extracting the schemaLocation, depending.

The project: https://bitbucket.org/djarvis/validating-catalog-resolver/

The offending code:
https://bitbucket.org/djarvis/validating-catalog-resolver/raw/master/src/TestXSD.java

The most problematic parts of the code are the:

* getSchemaURI method; and
* if( schemaURI != null ) { ... } code block.

I think that they are redundant, but do not know what mechanisms are
available to avoid having to manually parse and validate against an
XSD whose file path is looked up using an XML catalog. Ideally, the
XML file would only have to be parsed once. I'd like to avoid using
the SAX2DOM class, if possible.

The code works, but there must be a better way.

How can parsing the processing instruction and manually calling a
SchemaFactory for validation of the DOM be eliminated?

How can using both XMLCatalogResolver and CatalogResolver be avoided
(e.g., is an LSResourceResolver required)?

Any other comments, critiques, and corrections are most welcome.

Thank you.


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS