RE: [xsl] Simulate schema-awareness to create comboBoxes

Subject: RE: [xsl] Simulate schema-awareness to create comboBoxes
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 28 Nov 2006 18:11:35 -0000
Neither the XSLT 2.0 spec, nor Saxon, currently offers you the ability to
introspect the schema in the way you want. I think that what you actually
need is some kind of access to the finite state machine produced by
compiling the schema. It might be possible to achieve this with suitable
extension functions, but it's not going to be easy. The information is
there, but not in very accessible form.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Angela Williams [mailto:Angela.Williams@xxxxxxxxxxxxxxxxxx]
> Sent: 28 November 2006 18:01
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Simulate schema-awareness to create comboBoxes
>
> Hello -
>
> I need some advice, please.  I have a multi-step problem and
> am not sure the best direction to take. I've tried a few
> different options, but surely someone has already solved this
> more elegantly than what I am doing.... I am attending
> <XML2006> and thought I could wait, but need to come up with
> something before then...
>
> Step 1: I need the global elements in a schema to be
> represented as options in comboBoxes on a JSF page.
>
> Step 2: I need to compare the user choices (in the instance
> document) against the schema to dynamically add or remove
> options from the comboBox according to the schema cardinality.
>
> I can write a stylesheet to parse the schema to provide the
> lists, but that just gives me a superset and doesn't account
> for cardinality. And I would still have to continue to
> compare the instance doc against the parsed schema to update
> the comboBoxes as the user makes choices.
>
> I'm using W3C XML Schema, XSLT 2.0, XPath 2.0 and Saxon8.  We
> have a license for SaxonSA, but it either doesn't offer the
> type of functionality I need or I just didn't recognize it.
>
> Schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>
>   <xs:element name="root">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element ref="Item-A" minOccurs="0" maxOccurs="1" />
>         <xs:element ref="Item-B" minOccurs="1"
> maxOccurs="unbounded" />
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
>
>   <xs:element name="Item-A" type="a-type"/>
>   <xs:element name="Item-B" type="b-type"/>
>
>   <xs:complexType name="a-type"/>
>   <xs:complexType name="b-type"/>
>
> </xs:schema>
>
> Instance 1 > Only option should be 'Item-B':
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
>    <Item-A/>
> </root>
>
> Instance 2 > Options should be 'Item-A' and 'Item-B':
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
>    <Item-B/>
> </root>
>
> If someone could point me in the right direction, I would
> greatly appreciate it!
>
> Thanks!
> Angela Williams
> Channel Developer
> The 401k Company
> 512-344-1547
>  

Current Thread