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]
Re: [xml-dev] Catalog Resolver for XSD and XSLT

> 
> My understanding is that Saxon 9 does not have full XSLT 1 support.
> Unfortunately, both XSLT 1 and XSLT 2 documents are used.

An XSLT 2 processor will run XSLT 1 stylesheets correctly unless they do very pathological things which are almost certainly errors (such as the construct A > B > C).
> 
> If it was only XSLT 2, then it would be easier, but still problematic.
> 
> The XsltTransformer cannot use XmlCatalogResolver because it does not
> implement the URIResolver interface. That seems a bit strange.

XsltTransformer has a method setURIResolver(), so I don't understand your difficulty here.
> 
> 
> There's a wrench in the works. Some XML documents specify the
> stylesheet with the "xml-stylesheet" processing instruction. Such as:
> 
> <?xml-stylesheet type="text/xsl"
> href="http://stackoverflow.com/2014/09/xsl/notes/notes.xsl";?>

There's no direct support for the xml-stylesheet processing instruction in the s9api interface, but you can use the free-standing static method

PreparedStylesheet,getAssociatedStylesheet()

This takes as input a Source object representing the source document. This means you can either build the source document first, or you can supply it as a StreamSource - Saxon will parse it only as far as the processing instruction. This method uses the URIResolver associated with the Configuration. 
> 
> 
> 
> Unless I am mistaken, using a catalog resolver with S9 is only a minor
> reduction in code. Overall, it appears to have similar deficiencies as
> JAXP.

It's designed to handle common use cases well. Using xml-stylesheet processing instructions isn't a common use case, except when running in the browser.
> 
>> No mention here of a catalog resolver, but you can use one if you want.
> 
> How do you use a catalog resolver, an XSD for vaildation, and an XSL
> template URI specified in the XML document (to validate and
> transform)? For example:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-model type="application/xml"
> href="http://stackoverflow.com/2014/09/xsd/notes/notes.xsd";?>
> <?xml-stylesheet type="text/xsl"
> href="http://stackoverflow.com/2014/09/xsl/notes/notes.xsl";?>
> <note>
>    <title>Shopping List</title>
>    <date>2014-08-30</date>
>    <body>headlight fluid, flamgrabblit, exhaust coil</body>
> </note>
> 
> How would the above XML be validated and transformed using S9's API
> alone? (Presumably the transformation step would not happen if the XML
> file failed validation.)
> 
> 

I think that's the first time you mentioned <?xml-model?>. There's no support for that in Saxon, you'll have to extricate that yourself.

I don't actually think it's a good idea for source documents to reference the schema that should be used to validate them. How do you validate that they reference the right schema? Saxon does support xsi:schemaLocation, because it's so widely used and is part of the XSD spec, but you will have to handle xml-model yourself, which makes things a bit more difficult.

Michael Kay
Saxonica



[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