Re: Default Attributes and XSD

Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> Sat, 13 Mar 2021 08:01:05 +0000
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
Validating XML against a schema will expand the attribute values and will also add type annotations to the nodes.

There are many ways you can retain the expanded defaults while discarding the type annotations, The simplest way is just to serialize the XML immediately after validation - with s9api, just send the output of a SchemaValidator to a Serializer. The s9api interface tends to work much better for this than JAXP interfaces because it's more tightly integrated (JAXP, for example, struggles if you want to separate schema validation from XML parsing).

The constraint of only doing one transformation pass seems a rather artificial one and I'm not sure what the real constraint is. Similarly, the constraint of not doing schema-aware transformation. 

Michael Kay
Saxonica

> On 12 Mar 2021, at 12:49, Christophe Marchand <[email protected]> wrote:
> 
> Marko, you can have a look at a custom SAXParserFactory [1] that *should* be able to load files with default values from schema, if schema is referenced from XML with a xsl:schemaLocation  or a xsi:noNamespaceSchemaLocation.
> 
> I had no time to test it, but you should be able to start Saxon with this Factory from command line (-x:... option).
> 
> Feel free to use this code as you like, but be careful, it is not tested, and there are strict limitations, mainly multiple schema are not supported.
> 
> Hope that helps,
> Christophe
> 
> Le 11/03/2021 à 20:30, Marko Hedler a écrit :
>> Hi Wendell,
>>> If on the other hand the XSD is relatively stable, a way to do this
>>> would be to run an XSLT to produce your list of values from the schema
>>> (once), then use that values list (expressed in XML or XSLT) as a
>>> component within your XSLT runtime (many times). So the two passes are
>>> distinct and loosely coupled. You are merely giving your XSLT a "look
>>> up a default" capability, then externalizing the declarations in your
>>> XSD to support that.
>> 
>> I think, this could be the way to go. I'll give it a try.
>> 
>> Thanks a lot.
>> Cheers
>> Marko
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> saxon-help mailing list archived at http://saxon.markmail.org/
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/saxon-help 
> 
> 
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help



_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help