On 26.Jul.2001 -- 11:08 AM, Torsten Curdt wrote:
> Well, without a session the whole instance data has to be posted
> for each subpage. When thinking of a 5 pages form this can be a lot
> of data... the current design just posts the data of the current
> subpage controls. This would be less than 1/5 of the whole instance
> data!! BTW: that's the usual way

OK, got it.

> I thought it was an alternative to specifiying the xform attribute.
> Anyway... Could you correct the xform.xml then please?
> So we have correct example to try with...

Attached it the one I'm currently trying to get bindings to work
properly. There might be other examples on www.mozquito.org but I
wasn't able to load the examples with my current browser (requires
java script).

> > > This also how we could define the errors or validation
> > > constrains...
> > 
> > One idea could be to use what Konstantin said about error elements in
> > the instance data. Messages would be presented by using output
> > elements referencing these error instances. If they are empty, no
> > error message is presented to the user.
> 
> Yes. This might be a good sollution. But where are the error message
> specified?! The instance would only hold a copy of them...

Would have to be done by the validation process(?)

> > I reckon daily usage would make a taglib necessary, that translates
> > some even more abstract input controls to xform input controls. But
> > that's probably very application specific.
> 
> Could you give an example?

I reckon that a (content) designer might be most happy by writing

  <orderForm:FirstName/>

than have to write the complete 
     <xform:textbox....>
        <caption>...
        ...
     </xform:textbox>

OK, most likely a little bit more than just <oderForm:FirstName/>

> > This information (that there is a checkbox "foo") is contained in the
> > information that is needed by the validation process. Otherwise it
> > wouldn't be able to check "foo".
> 
> Exactly - that's the problem. This information is only available
> in the descriptor by selecting via XPath 
>"//sel:page[@name='page']/(descendant::xform:textbox|descendant::xform:checkbox)"
> or via PageRegistry.
> The descriptor+XPath way gives us unwanted dependancy of the sel:page element
> (and it is a hell of an expression ;) ... but maybe we can cache this
> nodelist in our action as well...
> 
> Hm... what about this:
> 
>    <map:match pattern="xform.html">
>     <map:act type="XFormAction">
>       <map:parameter name="pageroot" value="//sel:page[@name='$page$']"/>
>       <map:parameter name="default" value="fillin1"/>
>       <map:generate type="serverpages" src="docs/samples/xform/xform.xml">
>         <map:parameter name="page" value="{page}"/>
>       </map:generate>
>     </map:act>
>     <map:transform src="stylesheets/xform2html.xsl"/>
>     <map:serialize type="html"/>
>    </map:match>
> 
> This would specifiy the path to the root node. We only would
> have to replace the $page$ (unfortunately {page} cannot work)

Why? (No idea what you're at.)

> by the page the action receives the data from. Then we have
> the root node of the suppage and we can make a select
> "descendant::xform:textbox|descendant::xform:checkbox" to get
> the expected elements. if we cache the nodelists with the
> pageroot expression as key in a Hashtable or somehting we
> should really have little expense...
> We can also provide the "//sel:page[@name='$page$']" expression
> as default value so you only have to change it if you
> don't use the sel:logicsheet...
> 
> Cool!

> > There's more to it. You need to determine wich form got submitted
> > since you can not split it to different HTML forms as they cannot be
> > nested or mixed. So a sitemap component has to find out which one is
> > the right one and "redirect" to the appropriate URI. "redirect"
> > because the request object has to be maintained. What about forms that
> > submit to a different site (or a part of the site that's not
> > controlled by C2)? (not solvable?)
> 
> I don't see the problem could you explain a bit more.
> The action already knows about which http form was submitted.

In short: HTML forms may not be nested, XForms may. So several XForms
will be combined into a single HTML form having several submit
buttons. Need to find out which one was used + send data to correct
target as different XForms may have different submit targets.

> > I hope to have a stylesheet tomorrow that does the full binding
> > stuff. After that I'll look into a multiple forms actor or into
> > validation.

Unfortunately, it looks like I haven't got a clue about advanced XPath
expressions and XForms contains more and more complicated issues than
I anticipated. So here is a tiny stylesheet that copies instance data
to a value child element of xforms controls. It's far from perfection,
greatest shortcomings are it doesn't do scoped binding or indirect
binding and it uses xalan's evaluate extension. But for the moment it
might be useful anyway. I hope that I'll be able to follow up on the
binding issues.


        Chris.

-- 
C h r i s t i a n       H a u l
[EMAIL PROTECTED]
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsp:page
  language="java"
  xmlns:xsp="http://apache.org/xsp";
  xmlns:xform="http://www.w3.org/2001/06/xforms";
  xmlns:sel="http://apache.org/xsp/sel/1.0";
  >


<root>
  <xform:xform id="orderForm">
    <xform:submitInfo target="http://orderForm/target"; method="POST"/>
    <xform:model/>
    <xform:instance>
      <order>
        <firstname>Torsten</firstname>
        <lastname/>
        <email>[EMAIL PROTECTED]</email>
        <city/>
        <country/>
        <newsletter/>
      </order>
    </xform:instance>
  </xform:xform>  
  <xform:xform id="nextPage1">
    <xform:submitInfo target="http://nextPage1/target"; method="POST"/>
    <xform:model/>
    <xform:instance>
      <link-target id="id1234">showCart</link-target>
      <cart-id id="id562">1234567</cart-id>
      <view>
      </view>
    </xform:instance>
  </xform:xform>  

  <sel:selector type="sitemap" parameter="page">
    <sel:case name="fillin1">
      <p>Please enter your name and email address</p>

        <xform:textbox ref="order/firstname">
          <caption>Firstname</caption>
        </xform:textbox>

        <xform:textbox ref="order/lastname">
          <caption>Lastname</caption>
        </xform:textbox>

        <xform:textbox ref="order/email">
          <caption>Email</caption>
        </xform:textbox>

    </sel:case>

    <sel:case name="fillin2">
      <p>Please enter where you are located</p>

      <xform:textbox ref="order/city" xform="orderForm">
        <caption>City</caption>
      </xform:textbox>

      <xform:selectOne ref="order/country" xform="orderForm">
        <caption>Country</caption>
        <hint>Please select the country you are from</hint>
        <choices>
          <item value="none">Please select</item>
          <item value="DE">Germany</item>
          <item value="US">USA</item>
          <item value="UK">United Kingdom</item>
        </choices>
      </xform:selectOne>

      <xform:selectBoolean ref="order/newsletter" xform="orderForm">
        <caption>Newsletter</caption>
        <choices>
          <item value="true">Yes</item>
          <item value="false">No</item>
        </choices>
      </xform:selectBoolean>
    </sel:case>

    <sel:case name="overview">
      
        <p>Is everything correct?</p>
    
        <xform:output ref="/order/firstname"/>
        <xform:output ref="order/lastname"/>
        <xform:output ref="order/email"/>
        <xform:output ref="order/city"/>
        <xform:output ref="order/country"/>

        <xform:output ref="id(id1234)"/>

    </sel:case>

    <sel:case name="thanks">
      <p>Thank you!</p>
    </sel:case>

    <sel:otherwise>
      <p>Hm.. how did you get here?</p>
    </sel:otherwise>
  </sel:selector>

  <xform:submit/>


</root>

</xsp:page>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:xform="http://www.w3.org/2001/06/xforms";
   xmlns:xalan="http://xml.apache.org/xalan";
   exclude-result-prefixes="xalan"
>

  <!-- 
   extension-element-prefixes="xalan"
   xmlns:lxslt="http://xml.apache.org/xslt";
       Binding
       
       @ref references instance
            scoped references (any ancestor uses absolute ref and this one only 
relative)
            id references
       
       <xform:bind/> element, child of <xform:form/> allows indirect binding

       references node set, only first is used

       multiple forms ==> defaults to first, otherwise needs @xform id

       if element is in xform ns
          and not part of a xform element
          then
              if has @ref attribute
                  if @ref is absolute (starts with /)
                      use @ref to construct path
                      if has @xform attribute
                          references instance data of that form
                      else
                          references instance data of first form
                      fi
                  else if @ref is of type id
                      locate element with id(@id)
                      if local-name() == "bind"
                          # does indirect binding require xform attribute?
                          reference instance data of that form
                      else
                          use data
                      fi
                  else
                      if ancestor::*[@ref]
                          construct path from ancestor::*[@ref]@ref+@ref
                      fi
                      if has @xform
                          reference instance data of that form
                      else
                          reference instance data of first form
                      fi
                  fi
               fi
        fi

       -->

   <!-- frequently used paths 
        xform declaration should be in document head. however, xsp does not
        necessarily have a head element. So match them anywhere in the document.
        This should be changed in a later revision.
        -->
   <xsl:variable 
name="instance-path1">//*[namespace-uri(.)="http://www.w3.org/2001/06/xforms"; and 
local-name(.)="xform"</xsl:variable>
   <xsl:variable 
name="instance-path2">]/*[namespace-uri(.)="http://www.w3.org/2001/06/xforms"; and 
local-name(.)="instance"]</xsl:variable>
   <!-- to use @id attributes either DTD or xsl:key is necessary -->
   <xsl:key name="form-id" 
match="//*[namespace-uri(.)='http://www.w3.org/2001/06/xforms' and 
local-name(.)='xform']//*" use="@id"/>


   <!-- match anything that is an xforms element but not inside a xform declaration -->
   <xsl:template match="//*[namespace-uri(.)='http://www.w3.org/2001/06/xforms' and 
not(local-name(.)='xform') and not(ancestor::xform:xform)]">
     <xsl:variable name="value">
       <xsl:choose>
         <xsl:when test="@ref">
           <xsl:choose>
             <xsl:when test="starts-with(@ref,'/')"><!-- absolute reference -->
               <xsl:choose>
                 <xsl:when test="@xform"><!-- bound to specific xform -->
                   <xsl:value-of select="xalan:evaluate(concat($instance-path1,' and 
@id=&quot;',@xform,'&quot;',$instance-path2,@ref))"/>
                 </xsl:when>
                 <xsl:otherwise><!-- default xform i.e. first. -->
                 <!-- This is incorrect behaviour as it doesn't care if e.g. first 
xform doesn't have 
                      such an instance. It matches *any* xform instance that conforms 
to this path -->
                   <xsl:value-of 
select="xalan:evaluate(concat($instance-path1,$instance-path2, @ref))"/>
                 </xsl:otherwise>
               </xsl:choose>
             </xsl:when>
             <xsl:when test="starts-with(@ref,'id')"><!-- reference contains 'id' -->
             <!-- This behaviour is incorrect in that it doesn't bother with bind 
elements i.e. indirect binding -->
               <xsl:value-of 
select="key('form-id',substring(@ref,4,string-length(@ref)-4))"/>
             </xsl:when>
             <xsl:otherwise><!-- 'normal' reference -->
             <!-- This behaviour is incorrect in that it doesn't do scoped binding -->
               <xsl:value-of 
select="xalan:evaluate(concat($instance-path1,$instance-path2,'/',@ref))"/>
             </xsl:otherwise>
           </xsl:choose>
         </xsl:when>
         <xsl:otherwise>           
            <!-- is there a defined behaviour if @ref is not present? -->
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <xsl:copy>
       <value><xsl:value-of select="$value"/></value>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
   </xsl:template>
       

   <xsl:template match="@*|node()" priority="-1">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
   </xsl:template>

</xsl:stylesheet>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to