Re: What SAXON extension (?) enables my XSLT program to get information about XSD elements?

"Dr. Roger L Costello" <[email protected]>
Newsgroups gmane.text.xml.saxon.help
Message-ID <DM6PR09MB33374B03A2985043C82F0BC9C8660@DM6PR09MB3337.namprd09.prod.outlook.com>
Hi Michael,

My schema consists of many schema files. Part of the information that I want to collect for each element is the name of the schema file in which the element is declared. It appears that the SCM does not include the filename information. Is that true? If so, what is your recommendation for obtaining that information?

/Roger

-----Original Message-----
From: Dr. Roger L Costello <[email protected]> 
Sent: Tuesday, July 7, 2020 1:21 PM
To: Mailing list for the SAXON XSLT and XQuery processor <[email protected]>
Subject: Re: [saxon] What SAXON extension (?) enables my XSLT program to get information about XSD elements?

> you can export the schema to an SCM file, 
> which is an XML file containing the schema 
> component model

Ha! That's it, SCM. Thanks Michael. SCM is just what I want.

/Roger

-----Original Message-----
From: Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> 
Sent: Tuesday, July 7, 2020 12:46 PM
To: Mailing list for the SAXON XSLT and XQuery processor <[email protected]>
Subject: [EXT] Re: [saxon] What SAXON extension (?) enables my XSLT program to get information about XSD elements?

There are two ways of doing this.

Firstly, you can export the schema to an SCM file, which is an XML file containing the schema component model, in a form very close to the way the spec describes it. This means you get access to all the SCM-defined properties directly, for example to ask if an element is mixed content you ony have to look in one place, rather than following lots of inheritance hierarchies.

Secondly, you can get the same information through extension functions. Start with saxon:schema() (which is where the documentation is: http://www.saxonica.com/documentation/index.html#!functions/saxon/schema ).

The data is presented through functions. It was implemented before maps came along, and would have been done using maps if they'd been available at the time, but it works in much the same way. E.g.

let $bookDecl := saxon:schema('element declaration', QName('', 'book'))

finds an element declaration in the form of a function, which you can call to get information:
 
if ($bookDecl('type definition')('variety') = 'element-only') ...

(Actually, doing this with maps would be a little tricky because the structures are cyclic; but that's a separate topic...)


Michael Kay
Saxonica


> On 7 Jul 2020, at 16:30, Dr. Roger L Costello <[email protected]> wrote:
> 
> Hi Folks,
> 
> I want to write an XSLT program that traverses the leaf elements of XML instance documents. As the XSLT program visits each element, the program goes to the element declaration in the corresponding XML Schema and collects schema-information about the element, such as minOccurs, maxOccurs, type, default, fixed, and facets (if applicable). I believe that SAXON has an extension (?) which provides access to all sorts of valuable information about the XML Schema. I believe that I used the extension (?) long ago, but I've forgotten what its name is. Would you point me to the thing that I am looking for, please?
> 
> /Roger
> 
> 
> _______________________________________________
> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.