Thread: [Xsltforms-support] Cross instance XPath evaluation
Brought to you by:
alain-couthures
From: William V. <wi...@bi...> - 2011-07-20 13:32:35
|
Hello everybody, Below in this message is a simplified example of form for editing a bug in a bug tracking system based on XForms. The idea is having a separate instance (id=states) with the rules of the bug tracking system indicating which fields should be read-only, relevant and/or required according to the current state of the bug. Is it possible to do this in xsltforms? As you can see with the example, neither the conditions or even the xforms:output can handle xpath expressions like this: instance('states')/State[@id=instance('bug')/State]/@require-commen <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl" ?> <?xsltforms-options debug="yes" lang="es" ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events"> <head> <title>Conditional Relevant and Required Test</title> <style type="text/css"> @namespace xforms url("http://www.w3.org/2002/xforms"); body { font-family: Helvetica;sans-serif;} label.xforms-label { display:block;} </style> <xforms:model id="xmod"> <xforms:instance id="bug"> <Bug> <ID/> <Date/> <CurrentState>new</CurrentState> <Subject/> <Description/> <Comment/> </Bug> </xforms:instance> <xforms:instance id="states"> <States> <State id="new" can-edit="true" require-comment="false" show-comment="false"/> <State id="assigned" can-edit="true" require-comment="false" show-comment="true"/> <State id="solved" can-edit="true" require-comment="true" show-comment="true"/> <State id="verified" can-edit="true" require-comment="false" show-comment="true"/> <State id="tested" can-edit="true" require-comment="false" show-comment="true"/> <State id="closed" can-edit="false" require-comment="false" show-comment="false"/> </States> </xforms:instance> <xforms:bind nodeset="/Bug/Date" type="xsd:date" required="true()"/> <xforms:bind nodeset="/Bug/State" type="xsd:string" required="true()"/> <xforms:bind nodeset="/Bug/Subject" type="xsd:string" readonly="not(instance('states')/State[@id=instance('bug')/State]/@can-edit)"/> <xforms:bind nodeset="/Bug/Description" type="xsd:string" readonly="not(instance('states')/State[@id=instance('bug')/State]/@can-edit)" /> <xforms:bind nodeset="/Bug/Comment" type="xsd:string" relevant="instance('states')/State[@id=instance('bug')/State]/@show-comment" required="instance('states')/State[@id=instance('bug')/State]/@require-comment"/> </xforms:model> </head> <body> <xforms:group ref="/Bug" model="xmod"> <xforms:input ref="ID" model="xmod"> <xforms:label>Bug ID</xforms:label> </xforms:input> <xforms:input ref="Date" model="xmod"> <xforms:label>Bug Date</xforms:label> </xforms:input> <xforms:select1 ref="CurrentState" model="xmod"> <xforms:label>State</xforms:label> <xforms:itemset model="xmod" nodeset="instance('states')/State"> <xforms:label ref="@id"/> <xforms:value ref="@id"/> </xforms:itemset> </xforms:select1> <xforms:input ref="Subject" model="xmod"> <xforms:label>Subject</xforms:label> </xforms:input> <xforms:textarea ref="Description" model="xmod"> <xforms:label>Bug Description</xforms:label> </xforms:textarea> <xforms:textarea ref="Comment" model="xmod"> <xforms:label>Comments</xforms:label> </xforms:textarea> </xforms:group> <xforms:group ref="" model="xmod"> <xforms:label>Rules for this State</xforms:label> <xforms:output ref="instance('bug')/CurrentState" model="xmod"> <xforms:label>Current State</xforms:label> </xforms:output> <xforms:output ref="instance('states')/State[@id=instance('bug')/CurrentState]/@can-edit" model="xmod"> <xforms:label>Can edit Bug</xforms:label> </xforms:output> <xforms:output ref="instance('states')/State[@id=instance('bug')/CurrentState]/@show-comment" model="xmod"> <xforms:label>Show comment field</xforms:label> </xforms:output> <xforms:output ref="instance('states')/State[@id=instance('bug')/CurrentState]/@require-comment" model="xmod"> <xforms:label>Comment Required</xforms:label> </xforms:output> </xforms:group> </body> </html> |
From: Alain C. <ala...@ag...> - 2011-07-20 18:53:12
|
Hello William, It is very important to add xmlns="" at your instances because latest releases of FireFox are capitalizing attribute names when in the xhtml namespace. I clearly see a difference with this and it seems OK for me now. Can you please confirm? Thanks! -Alain Le 20/07/2011 15:32, William Velasquez a écrit : > Hello everybody, > > Below in this message is a simplified example of form for editing a > bug in a bug tracking system based on XForms. > > The idea is having a separate instance (id=states) with the rules of > the bug tracking system indicating which fields should be read-only, > relevant and/or required according to the current state of the bug. > > Is it possible to do this in xsltforms? As you can see with the > example, neither the conditions or even the xforms:output can handle > xpath expressions like this: > instance('states')/State[@id=instance('bug')/State]/@require-commen > > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl" ?> > <?xsltforms-options debug="yes" lang="es" ?> > <html xmlns="http://www.w3.org/1999/xhtml" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:xforms="http://www.w3.org/2002/xforms" > xmlns:ev="http://www.w3.org/2001/xml-events"> > <head> > <title>Conditional Relevant and Required Test</title> > <style type="text/css"> > @namespace xforms url("http://www.w3.org/2002/xforms"); > body { font-family: Helvetica;sans-serif;} > label.xforms-label { display:block;} > </style> > <xforms:model id="xmod"> > <xforms:instance id="bug"> > <Bug> > <ID/> > <Date/> > <CurrentState>new</CurrentState> > <Subject/> > <Description/> > <Comment/> > </Bug> > </xforms:instance> > <xforms:instance id="states"> > <States> > <State id="new" can-edit="true" require-comment="false" > show-comment="false"/> > <State id="assigned" can-edit="true" require-comment="false" > show-comment="true"/> > <State id="solved" can-edit="true" require-comment="true" > show-comment="true"/> > <State id="verified" can-edit="true" require-comment="false" > show-comment="true"/> > <State id="tested" can-edit="true" require-comment="false" > show-comment="true"/> > <State id="closed" can-edit="false" require-comment="false" > show-comment="false"/> > </States> > </xforms:instance> > <xforms:bind nodeset="/Bug/Date" type="xsd:date" required="true()"/> > <xforms:bind nodeset="/Bug/State" type="xsd:string" required="true()"/> > <xforms:bind nodeset="/Bug/Subject" type="xsd:string" > readonly="not(instance('states')/State[@id=instance('bug')/State]/@can-edit)"/> > <xforms:bind nodeset="/Bug/Description" type="xsd:string" > readonly="not(instance('states')/State[@id=instance('bug')/State]/@can-edit)" > /> > <xforms:bind nodeset="/Bug/Comment" type="xsd:string" > relevant="instance('states')/State[@id=instance('bug')/State]/@show-comment" > required="instance('states')/State[@id=instance('bug')/State]/@require-comment"/> > </xforms:model> > </head> > <body> > <xforms:group ref="/Bug" model="xmod"> > <xforms:input ref="ID" model="xmod"> > <xforms:label>Bug ID</xforms:label> > </xforms:input> > <xforms:input ref="Date" model="xmod"> > <xforms:label>Bug Date</xforms:label> > </xforms:input> > <xforms:select1 ref="CurrentState" model="xmod"> > <xforms:label>State</xforms:label> > <xforms:itemset model="xmod" nodeset="instance('states')/State"> > <xforms:label ref="@id"/> > <xforms:value ref="@id"/> > </xforms:itemset> > </xforms:select1> > <xforms:input ref="Subject" model="xmod"> > <xforms:label>Subject</xforms:label> > </xforms:input> > <xforms:textarea ref="Description" model="xmod"> > <xforms:label>Bug Description</xforms:label> > </xforms:textarea> > <xforms:textarea ref="Comment" model="xmod"> > <xforms:label>Comments</xforms:label> > </xforms:textarea> > </xforms:group> > <xforms:group ref="" model="xmod"> > <xforms:label>Rules for this State</xforms:label> > <xforms:output ref="instance('bug')/CurrentState" model="xmod"> > <xforms:label>Current State</xforms:label> > </xforms:output> > <xforms:output > ref="instance('states')/State[@id=instance('bug')/CurrentState]/@can-edit" > model="xmod"> > <xforms:label>Can edit Bug</xforms:label> > </xforms:output> > <xforms:output > ref="instance('states')/State[@id=instance('bug')/CurrentState]/@show-comment" > model="xmod"> > <xforms:label>Show comment field</xforms:label> > </xforms:output> > <xforms:output > ref="instance('states')/State[@id=instance('bug')/CurrentState]/@require-comment" > model="xmod"> > <xforms:label>Comment Required</xforms:label> > </xforms:output> > </xforms:group> > </body> > </html> > > > > ------------------------------------------------------------------------------ > 10 Tips for Better Web Security > Learn 10 ways to better secure your business today. Topics covered include: > Web security, SSL, hacker attacks& Denial of Service (DoS), private keys, > security Microsoft Exchange, secure Instant Messaging, and much more. > http://www.accelacomm.com/jaw/sfnl/114/51426210/ > _______________________________________________ > Xsltforms-support mailing list > Xsl...@li... > https://lists.sourceforge.net/lists/listinfo/xsltforms-support > |