No way to get at instance data when xforms is created through xslt

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

No way to get at instance data when xforms is created through xslt

Bert-31
I want users to get an xform form when they open an xml data-file. I use
client-side xslt for this.
When I do so I can see the data in the model-instance using mozilla's
DOM-inspector, but I cannot use the data in the form.
When I do the XSLT translation "by hand", creating an xhtml-file, then
all does work, so the problem seems to be that mozilla does not
interpret the result of its XSLT transformation as xforms?
How do I get this to work (client-side)?
I am using mozilla thunderbird version 2.0.0.6 (20070902) on Linux and
the Mozilla XForms 0.8.0.3

Sample xml-file:

<?xml version="1.0" encoding="utf-8"?>
<?xml-schema type="text/xsd" href="demo.xsd"?>
<?xml-stylesheet type="text/xsl" href="demo.xsl"?>
<dossier xmlns="">
<dossiernummer>5126</dossiernummer>
<data>blah</data>
<datum>2007-09-20</datum>
</dossier>

Sample xslt file used:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" encoding="UTF-8" />

<xsl:template match="/">
        <xsl:apply-templates />
</xsl:template>

<xsl:template match="dossier">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <head>
     <xsl:variable name="dossiernummer" select="dossiernummer" />
     <meta http-equiv="Content-Type"
     content="text/html;charset=UTF-8" />
     <meta http-equiv="content-language" content="en" />
     <!-- <style type="text/css">@import url(sleuteltje.css);</style> -->
     <title>Demo dossier <xsl:value-of select="dossiernummer" /></title>
      <xf:model id="sleutel" schema="demo.xsd">
       <xf:instance id="dossier">
        <dossier xmlns="">
          <xsl:copy-of select="*" />
        </dossier>
<!-- I tried this also, but it made no difference; I can see the data in
the DOM inspector, but it is not used nor visisble in the form...
           <dossier xmlns="">
             <xsl:for-each select="*">
               <xsl:element name="{name()}" namespace="">
                <xsl:value-of select="." />
              </xsl:element>
             </xsl:for-each>
           </dossier>
-->
       </xf:instance>
       <xf:submission id="save-to-file" method="put"
       replace="all" src="{concat(substring('000000', 0, 7 -
string-length($dossiernummer)), $dossiernummer, '.xml')}" >
         <xf:action ev:event="xforms-submit-done">
           <xf:message level="modal">
                OK! De gegevens zijn opgeslagen.
          </xf:message>
         </xf:action>
       </xf:submission>
       <xf:action ev:event="xforms-submit-error">
         <xf:message level="modal">
                ERROR! <br/>De gegevens zijn nog NIET opgeslagen.
        </xf:message>
       </xf:action>
     </xf:model>
   </head>
   <body>

     <xf:repeat nodeset="instance(dossier)" id="test">
<!-- There is no way to display anything here, so the nodeset is
probably not found -->
       |<xf:output ref="." />
     </xf:repeat>

<!-- The following remains empty too -->
     <xf:group ref="/dossier">
       Dossiernummer: <xf:input ref="dossiernummer" /><br/>
       Data: <xf:input ref="data" /><br/>
       <xf:input  model="sleutel" ref="datum"
          ev:event="DOMActivate" ev:handler="#speak"
          accesskey="g"><xf:label>GEBOREN</xf:label>
          <xf:help>Geef de geboorte datum, bv: 19990423</xf:help>
          <xf:hint>Wanneer bent u geboren?</xf:hint>
          <xf:alert>De datum die u opgeeft <xf:output
ref="geboortedatum"/> is geen geldige datum.
          </xf:alert>
       </xf:input>
     </xf:group>

     <xf:trigger>
       <xf:label>Refresh</xf:label>
       <xf:action ev:event="DOMActivate">
         <xf:refresh model="sleutel"/>
       </xf:action>
     </xf:trigger>

<!-- This does not work either -->
     <xf:submit submission="save-to-file">
       <xf:caption>Opslaan</xf:caption>
     </xf:submit>

   </body>
</html>
</xsl:template>
</xsl:stylesheet>

Sample "hand-made" xhtml-file that does work:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Here i dit the XSLT translation "by hand". Now it mostly does work.-->
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <head>
     <meta http-equiv="Content-Type"
     content="text/html;charset=UTF-8" />
     <meta http-equiv="content-language" content="en" />
     <!-- <style type="text/css">@import url(sleuteltje.css);</style> -->
     <title>Demo dossier 5126</title>
      <xf:model id="sleutel" schema="demo.xsd"> <!--schema="demo.xsd" -->
       <xf:instance id="dossier">
        <dossier xmlns="">
<dossiernummer>5126</dossiernummer>
<data>blah</data>
<datum>2007-09-20</datum>
        </dossier>
       </xf:instance>
       <xf:submission id="save-to-file" method="put"
       replace="all" src="demo_save.xml" >
         <xf:action ev:event="xforms-submit-done">
           <xf:message level="modal">
                OK! De gegevens zijn opgeslagen.
          </xf:message>
         </xf:action>
       </xf:submission>
       <xf:action ev:event="xforms-submit-error">
         <xf:message level="modal">
                ERROR! <br/>De gegevens zijn nog NIET opgeslagen.
        </xf:message>
       </xf:action>
     </xf:model>
   </head>
   <body>

     <xf:repeat nodeset="instance(dossier)" id="test">
<!-- There is no way to display anything here, so the nodeset is
probably not found -->
       |<xf:output ref="." />
     </xf:repeat>

<!-- The following remains empty too -->
     <xf:group ref="/dossier">
       Dossiernummer: <xf:input ref="dossiernummer" /><br/>
       Data: <xf:input ref="data" /><br/>
       <xf:input  model="sleutel" ref="datum"
          ev:event="DOMActivate" ev:handler="#speak"
          accesskey="g"><xf:label>GEBOREN</xf:label>
          <xf:help>Geef de geboorte datum, bv: 19990423</xf:help>
          <xf:hint>Wanneer bent u geboren?</xf:hint>
          <xf:alert>De datum die u opgeeft <xf:output
ref="geboortedatum"/> is geen geldige datum.
          </xf:alert>
       </xf:input>
     </xf:group>

     <xf:trigger>
       <xf:label>Refresh</xf:label>
       <xf:action ev:event="DOMActivate">
         <xf:refresh model="sleutel"/>
       </xf:action>
     </xf:trigger>

<!-- This does not work either -->
     <xf:submit submission="save-to-file">
       <xf:caption>Opslaan</xf:caption>
     </xf:submit>

   </body>
</html>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: No way to get at instance data when xforms is created through xslt

Aaron Reed
Hi Bert,

The problem with client side XSLT is that it is done after page load and
the normal parsing doesn't occur over the xforms elements.  More
information is contained in this bug:
https://bugzilla.mozilla.org/show_bug.cgi?id=294612

--Aaron

Bert wrote:

> I want users to get an xform form when they open an xml data-file. I use
> client-side xslt for this.
> When I do so I can see the data in the model-instance using mozilla's
> DOM-inspector, but I cannot use the data in the form.
> When I do the XSLT translation "by hand", creating an xhtml-file, then
> all does work, so the problem seems to be that mozilla does not
> interpret the result of its XSLT transformation as xforms?
> How do I get this to work (client-side)?
> I am using mozilla thunderbird version 2.0.0.6 (20070902) on Linux and
> the Mozilla XForms 0.8.0.3
>
> Sample xml-file:
>
> <?xml version="1.0" encoding="utf-8"?>
> <?xml-schema type="text/xsd" href="demo.xsd"?>
> <?xml-stylesheet type="text/xsl" href="demo.xsl"?>
> <dossier xmlns="">
> <dossiernummer>5126</dossiernummer>
> <data>blah</data>
> <datum>2007-09-20</datum>
> </dossier>
>
> Sample xslt file used:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="xml" encoding="UTF-8" />
>
> <xsl:template match="/">
>     <xsl:apply-templates />
> </xsl:template>
>
> <xsl:template match="dossier">
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:xf="http://www.w3.org/2002/xforms"
> xmlns:ev="http://www.w3.org/2001/xml-events"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>   <head>
>     <xsl:variable name="dossiernummer" select="dossiernummer" />
>     <meta http-equiv="Content-Type"
>     content="text/html;charset=UTF-8" />
>     <meta http-equiv="content-language" content="en" />
>     <!-- <style type="text/css">@import url(sleuteltje.css);</style> -->
>     <title>Demo dossier <xsl:value-of select="dossiernummer" /></title>
>      <xf:model id="sleutel" schema="demo.xsd">
>       <xf:instance id="dossier">
>     <dossier xmlns="">
>          <xsl:copy-of select="*" />
>     </dossier>
> <!-- I tried this also, but it made no difference; I can see the data in
> the DOM inspector, but it is not used nor visisble in the form...
>           <dossier xmlns="">
>             <xsl:for-each select="*">
>               <xsl:element name="{name()}" namespace="">
>         <xsl:value-of select="." />
>           </xsl:element>
>             </xsl:for-each>
>           </dossier>
> -->
>       </xf:instance>
>       <xf:submission id="save-to-file" method="put"
>       replace="all" src="{concat(substring('000000', 0, 7 -
> string-length($dossiernummer)), $dossiernummer, '.xml')}" >
>         <xf:action ev:event="xforms-submit-done">
>           <xf:message level="modal">
>         OK! De gegevens zijn opgeslagen.
>       </xf:message>
>         </xf:action>
>       </xf:submission>
>       <xf:action ev:event="xforms-submit-error">
>         <xf:message level="modal">
>         ERROR! <br/>De gegevens zijn nog NIET opgeslagen.
>     </xf:message>
>       </xf:action>
>     </xf:model>
>   </head>
>   <body>
>
>     <xf:repeat nodeset="instance(dossier)" id="test">
> <!-- There is no way to display anything here, so the nodeset is
> probably not found -->
>       |<xf:output ref="." />
>     </xf:repeat>
>
> <!-- The following remains empty too -->
>     <xf:group ref="/dossier">
>       Dossiernummer: <xf:input ref="dossiernummer" /><br/>
>       Data: <xf:input ref="data" /><br/>
>       <xf:input  model="sleutel" ref="datum"
>          ev:event="DOMActivate" ev:handler="#speak"
>          accesskey="g"><xf:label>GEBOREN</xf:label>
>          <xf:help>Geef de geboorte datum, bv: 19990423</xf:help>
>          <xf:hint>Wanneer bent u geboren?</xf:hint>
>          <xf:alert>De datum die u opgeeft <xf:output
> ref="geboortedatum"/> is geen geldige datum.
>          </xf:alert>
>       </xf:input>
>     </xf:group>
>
>     <xf:trigger>
>       <xf:label>Refresh</xf:label>
>       <xf:action ev:event="DOMActivate">
>         <xf:refresh model="sleutel"/>
>       </xf:action>
>     </xf:trigger>
>
> <!-- This does not work either -->
>     <xf:submit submission="save-to-file">
>       <xf:caption>Opslaan</xf:caption>
>     </xf:submit>
>
>   </body>
> </html>
> </xsl:template>
> </xsl:stylesheet>
>
> Sample "hand-made" xhtml-file that does work:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Here i dit the XSLT translation "by hand". Now it mostly does work.-->
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:xf="http://www.w3.org/2002/xforms"
> xmlns:ev="http://www.w3.org/2001/xml-events"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>   <head>
>     <meta http-equiv="Content-Type"
>     content="text/html;charset=UTF-8" />
>     <meta http-equiv="content-language" content="en" />
>     <!-- <style type="text/css">@import url(sleuteltje.css);</style> -->
>     <title>Demo dossier 5126</title>
>      <xf:model id="sleutel" schema="demo.xsd"> <!--schema="demo.xsd" -->
>       <xf:instance id="dossier">
>     <dossier xmlns="">
> <dossiernummer>5126</dossiernummer>
> <data>blah</data>
> <datum>2007-09-20</datum>
>     </dossier>
>       </xf:instance>
>       <xf:submission id="save-to-file" method="put"
>       replace="all" src="demo_save.xml" >
>         <xf:action ev:event="xforms-submit-done">
>           <xf:message level="modal">
>         OK! De gegevens zijn opgeslagen.
>       </xf:message>
>         </xf:action>
>       </xf:submission>
>       <xf:action ev:event="xforms-submit-error">
>         <xf:message level="modal">
>         ERROR! <br/>De gegevens zijn nog NIET opgeslagen.
>     </xf:message>
>       </xf:action>
>     </xf:model>
>   </head>
>   <body>
>
>     <xf:repeat nodeset="instance(dossier)" id="test">
> <!-- There is no way to display anything here, so the nodeset is
> probably not found -->
>       |<xf:output ref="." />
>     </xf:repeat>
>
> <!-- The following remains empty too -->
>     <xf:group ref="/dossier">
>       Dossiernummer: <xf:input ref="dossiernummer" /><br/>
>       Data: <xf:input ref="data" /><br/>
>       <xf:input  model="sleutel" ref="datum"
>          ev:event="DOMActivate" ev:handler="#speak"
>          accesskey="g"><xf:label>GEBOREN</xf:label>
>          <xf:help>Geef de geboorte datum, bv: 19990423</xf:help>
>          <xf:hint>Wanneer bent u geboren?</xf:hint>
>          <xf:alert>De datum die u opgeeft <xf:output
> ref="geboortedatum"/> is geen geldige datum.
>          </xf:alert>
>       </xf:input>
>     </xf:group>
>
>     <xf:trigger>
>       <xf:label>Refresh</xf:label>
>       <xf:action ev:event="DOMActivate">
>         <xf:refresh model="sleutel"/>
>       </xf:action>
>     </xf:trigger>
>
> <!-- This does not work either -->
>     <xf:submit submission="save-to-file">
>       <xf:caption>Opslaan</xf:caption>
>     </xf:submit>
>
>   </body>
> </html>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms