[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Catalog Resolver for XSD and XSLT

  • From: Thangalin <thangalin@gmail.com>
  • To: xml-dev@lists.xml.org
  • Date: Thu, 11 Sep 2014 15:50:25 -0700

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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.