开发者

Simple Xpath - reading child elements in XBL

I am using orbeon and I am trying to read child element defined in XBL. Here is how my xform definition looks like

<fr:foobar ref="mynode" constr开发者_开发技巧aint="unique">
  <fr:foo from="abc" to="def">
    <fr:bar key="id" name="primary" />
  </fr:foo>
</fr:foobar>

In XBL I can't seem to find an easy way to read the child element. I am obviously missing something simple.

<xforms:group xxbl:scope="inner">
    <!-- works -->
    <xxforms:variable name="foocontext">
        <xxforms:sequence select="{fr:foo/@from}" xxbl:scope="outer" />
    </xxforms:variable>

    <!-- does not works -->    
    <xxforms:variable name="barcontext" as="node()?">
        <xxforms:sequence select="{fr:foo/fr:bar}" xxbl:scope="outer" />
    </xxforms:variable>
</xforms:group>


An AVT always return text. So {fr:foo/fr:bar} is equivalent to {string(fr:foo/fr:bar)}, which in this case won't do what you expect. This is a tricky one, and I see two solutions:

  1. Don't define that XForms variable. Instead iterate over the structure in XSLT, and generate whatever XForms you want to generate. This is "most likely" the best way out (but don't believe what I say, since I don't even know what you are trying to do!).
  2. If you really need that variable, you'll need to copy those <fr:bar> elements into an instance with XSLT (<xsl:copy-of>), and then point to the nodes in that instance with the <xxforms:variable>.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜