Hello,
I want to make a XBL component that accepts a <xforms:label>, but if the user doesn't includes it, I want the component to provide a default label. Something like this: <xbl:binding id="my-binding" element="my|comp"> <xbl:template> <xforms:group xbl:attr="model context ref bind" xxbl:scope="outer"> <xbl:content includes="xforms|label"> <xforms:label>Default label</xforms:label> </xbl:content> </xforms:group> </xbl:template> </xbl:binding> So the user can use the component in this two different ways: <my:comp/> <my:comp> <xforms:label>Label one</xforms:label> </my:comp> This is based on the XBL specification for the content element (http://www.w3.org/TR/xbl/#the-content). Has this feature been implemented recently in Orbeon? I'm trying with version Orbeon Forms 3.8.0.post.201008110153 CE. If not already implemented, could it be implemented in future releases? Thanks in advance. jpereza. |
Does this work for you?
<xsl:variable name="label"> <xsl:choose> <xsl:when test="./xforms:label"> <xsl:value-of select="./xforms:label"/> </xsl:when> <xsl:otherwise>Default Label:</xsl:otherwise> </xsl:choose> </xsl:variable> <xforms:label> <xsl:copy-of select="$label" /> </xforms:label> Replace xbl:content with above snippet. |
Hi Binesh,
I've tried your snippet, and it works showing "Default Label" when the user doesn't put his own label. But if the user does provides his own label, it shows an empty label. But even if this solution gets working properly, I would like to use my initial solution: it's nicer, cleaner and conforms to the spec. Thanks. jpereza |
Agree that it would be cleaner if xbl:content can support default values.
|
Administrator
|
In reply to this post by jpereza
Here is where this should be implemented:
https://github.com/orbeon/orbeon-forms/blob/master/src/java/org/orbeon/oxf/xforms/xbl/XBLTransformer.java Are you able to give it a go? It shouldn't be too hard I think. -Erik On Fri, Nov 19, 2010 at 3:52 PM, jpereza <[hidden email]> wrote: > > Hi Binesh, > > I've tried your snippet, and it works showing "Default Label" when the user > doesn't put his own label. > But if the user does provides his own label, it shows an empty label. > > But even if this solution gets working properly, I would like to use my > initial solution: it's nicer, cleaner and conforms to the spec. > > Thanks. > > jpereza > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/xbl-content-does-not-conform-to-the-XBL-specification-tp3050150p3050436.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 > > -- 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 |
Hi Erik, thanks for answering.
I've made a change in XBLTransformer that works for me. But it would be better to check it before applying. At line number 87, change these lines: 87 } else { 88 contentToInsert = null; 89 } with these new lines: 87 } else { + // Clone all the element's children + contentToInsert = new ArrayList<Node>(element.nodeCount()); + for (Object o: element.elements()) { + final Element currentElement = (Element) o; + contentToInsert.add(Dom4jUtils.copyElementCopyParentNamespaces(currentElement)); + } 89 } Please, let me know if this change is well performed. jpereza. |
Administrator
|
Excellent: I have committed this:
https://github.com/orbeon/orbeon-forms/commit/38603a150f0b2eb0e1f5270cd531fb1f5195520f Thanks, -Erik On Tue, Nov 23, 2010 at 9:29 AM, jpereza <[hidden email]> wrote: > > Hi Erik, thanks for answering. > > I've made a change in XBLTransformer that works for me. But it would be > better to check it before applying. > > At line number 87, change these lines: > > 87 } else { > 88 contentToInsert = null; > 89 } > > with these new lines: > > 87 } else { > + // Clone all the element's children > + contentToInsert = new > ArrayList<Node>(element.nodeCount()); > + for (Object o: element.elements()) { > + final Element currentElement = (Element) o; > + > contentToInsert.add(Dom4jUtils.copyElementCopyParentNamespaces(currentElement)); > + } > 89 } > > > Please, let me know if this change is well performed. > > jpereza. > > -- > View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/xbl-content-does-not-conform-to-the-XBL-specification-tp3050150p3054988.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 > > -- 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 |
Free forum by Nabble | Edit this page |