Read data from schema?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Read data from schema?

Karolin Heiss
Hello

My schema contains information I want to use for xforms:label. Is it possible to read out data from the schema?

Depanding on the user language I want to set the belonging text:

<xs:documentation xml:lang="de">Mitarbeiter</xs:documentation>
<xs:documentation xml:lang="en">Employee</xs:documentation>
<xs:documentation xml:lang="fr">Employé</xs:documentation>


<xforms:model id="Empl_HierarchyEmployee201000SchemaType">

     <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
                <xs:element name="HierarchyEmployeeEmpl" type="HierarchyEmployeeEmplType"/>
                <xs:complexType name="HierarchyEmployeeEmplType">
                    <xs:sequence>
                        <xs:element name="Bookmark" type="BookmarkSimType"/>
                        <xs:element name="Employee" type="EmployeeComType" use="required">
                            <xs:annotation>
                                <xs:documentation xml:lang="de">Mitarbeiter</xs:documentation>
                                <xs:documentation xml:lang="en">Employee</xs:documentation>
                                <xs:documentation xml:lang="fr">Employé</xs:documentation>
                            </xs:annotation>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
           ........

Thank you for your help,

Karolin
Reply | Threaded
Open this post in threaded view
|

Re: Read data from schema?

Hank Ratzesberger-2
Hi Karolin,

I don't see any reason you cannot include a schema as an
XForms instance.  You would need to wrap it in a an XForms
instance element:

<xforms:instance id="my-schema">
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    ....
  </xs:schema>
</xforms:instance>

Or likely you will want to include the separate schema file:

<xforms:instance id="my-schema" src="my-schema.xsd"/>

Only I am not sure about xml namespace prefix, whether you need
this in your XPath statements:

<xforms:output ref="instance('my-schema')/xs:complexType[@name='HierarchyEmployeeEmplType']/xs:element[@name='Employee']/xs:annotation/xs:documentation[@lang='de']"/>

The above being my best guess.

Let us know how things proceed.

--Hank



On Aug 25, 2010, at 7:52 AM, Karolin Krieg wrote:

>
> Hello
>
> My schema contains information I want to use for xforms:label. Is it
> possible to read out data from the schema?
>
> Depanding on the user language I want to set the belonging text:
>
> <xs:documentation xml:lang="de">Mitarbeiter</xs:documentation>
> <xs:documentation xml:lang="en">Employee</xs:documentation>
> <xs:documentation xml:lang="fr">Employé</xs:documentation>
>
>
> <xforms:model id="Empl_HierarchyEmployee201000SchemaType">
>
>     <xs:schema attributeFormDefault="unqualified"
> elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
>                <xs:element name="HierarchyEmployeeEmpl"
> type="HierarchyEmployeeEmplType"/>
>                <xs:complexType name="HierarchyEmployeeEmplType">
>                    <xs:sequence>
>                        <xs:element name="Bookmark" type="BookmarkSimType"/>
>                        <xs:element name="Employee" type="EmployeeComType"
> use="required">
>                            <xs:annotation>
>                                <xs:documentation
> xml:lang="de">Mitarbeiter</xs:documentation>
>                                <xs:documentation
> xml:lang="en">Employee</xs:documentation>
>                                <xs:documentation
> xml:lang="fr">Employé</xs:documentation>
>                            </xs:annotation>
>                        </xs:element>
>                    </xs:sequence>
>                </xs:complexType>
>           ........
>
> Thank you for your help,
>
> Karolin
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Read-data-from-schema-tp2338360p2338360.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
Hank Ratzesberger
NEES@UCSB
Earth Research Institute
University of California, Santa Barbara
805-893-8042








--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Read data from schema?

Karolin Heiss
Hey Hank

Thankx, you are perfectly right!
It works like you suggested:

<xforms:input ref="apt:Phone2">
  <xforms:label>
    <xforms:output ref="$sch/xs:complexType/xs:sequence/xs:element[@name='Phone2']/xs:annotation/xs:documentation[@xml:lang='fr']"/>
  </xforms:label>
</xforms:input>

Do you know how I can set the language identifier ('fr', 'de'...) which is stored in an other xforms:instance?

<xforms:instance id="response-instance">
  <data xmlns="">
    <actionurl />
    <language />
    <response />
  </data>
</xforms:instance>

Thank you very much for your help,

Karolin
Reply | Threaded
Open this post in threaded view
|

Re: Re: Read data from schema?

Hank Ratzesberger-2
Hi Karolin,

Great news!  

The notation does get complex.  You might consider pre-processing the
schema into something simpler -- run it through xslt to make something
simpler.  The xxforms:cache option means that it will only happen one
time (I think at the application has to restart to update.)

ref=".....[@xml:lang=instance('response-instance')/language)]

will select the language.  As for setting the language, some of the
examples are probably better guides than me.  It is a good
practice to give the users an option to select.

The request processor can be used to inspect the http accept-language
header as well as the browser string to have some idea of the
language the user may select.

Cheers,
Hank

On Aug 27, 2010, at 12:14 AM, Karolin Krieg wrote:

>
> Hey Hank
>
> Thankx, you are perfectly right!
> It works like you suggested:
>
> <xforms:input ref="apt:Phone2">
>  <xforms:label>
>    <xforms:output
> ref="$sch/xs:complexType/xs:sequence/xs:element[@name='Phone2']/xs:annotation/xs:documentation[@xml:lang='fr']"/>
>  </xforms:label>
> </xforms:input>
>
> Do you know how I can set the language identifier ('fr', 'de'...) which is
> stored in an other xforms:instance?
>
> <xforms:instance id="response-instance">
>  <data xmlns="">
>    <actionurl />
>    <language />
>    <response />
>  </data>
> </xforms:instance>
>
> Thank you very much for your help,
>
> Karolin
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/Read-data-from-schema-tp2338360p2340696.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
Hank Ratzesberger
NEES@UCSB
Earth Research Institute
University of California, Santa Barbara
805-893-8042








--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws