Re: Default Attributes and XSD

"Bauman, Syd" <s.bauman-4Y/TWYOca5dXfO9P/[email protected]> Thu, 11 Mar 2021 15:29:09 +0000
Newsgroups gmane.text.xml.saxon.help
Message-ID <DM6PR06MB6089029DD10ECABDCE714118FC909@DM6PR06MB6089.namprd06.prod.outlook.com>
Indeed, this is not Saxon-specific, so may not be appropriate for this particular list — happy to move this conversation to the XSLT list or the XML Slack channel.

In any case, my first thought is that a 2-step solution would be to read in the schema (in this case XSD), and write out an XSLT that itself reads in an instance and writes out the same with defaulted attributes added.

I wrote such a system that did the opposite — removed attributes that had the default value — for RELAX NG over a decade ago. (I just looked: 12.98 years ago. :-)

________________________________

First it's useful to keep in mind that XSDs are not DTDs - most particularly, DTDs have no notion of local declarations.

This being the case, what you are asking is a tall order in the general case - for any (conformant) XSD.

It might not be so bad, however, for a particular XSD, if it happens to follow coding conventions making it more like a DTD (and simplifying the problem of matching attributes to their definitions). The approach would probably be to reduce your XSD with a filter (XSLT) into what would constitute essentially a lookup table for your attribute defaults, then reference that from your main XSLT.

Note this is not specifically a Saxon question, or answer.


using XSLT with SaxonEE 10.3, I want all default attribute values from a schema-valid XML instance to be expanded, but the XSLT-Transformation itself must not be schema-ware.

I would like to have the same behavior as transforming a DTD-valid XML instance with Saxon.

Any suggestions? Thanks in advance

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