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

Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]>
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
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
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.