Orbeon Forms では、次のようなインスタンスにバインドされたときに (XBL を使用して) コンポーネントを作成する必要があります。
<OCinstructionitem>
<OCp>paragraph 1</OCp>
<OCp>paragraph 2 <OCem>with italics part</OCem> rest of paragraph 2 </OCp>
</OCinstructionitem>
次のような編集可能な div を作成します。
<div contentEditable="true">
<p>paragraph 1</p>
<p>paragraph 2 <i>with italics part</i> rest of paragraph 2 </p>
</div>
私の考えでは、XSLT を使用してこれを行う必要があります。変換される XML が xforms ドキュメント内にある場合、これが機能します。
<oc:instructionitem>
<OCinstructionitem>
<!-- here the xml of above -->
...
</OCinstructionitem>
</oc:instructionitem>
しかし、次のようにバインドされたノードで XSLT を動作させたいと考えています。
<oc:instructionitem ref="OCinstructionitem"/>
ただし、バインドされたノードに XSLT からアクセスできません。
私の質問: それは不可能ですか? または、XBL を変更する必要がありますか?
私のXBLコード:
<xbl:binding id="oc-instructionitem" element="oc|instructionitem">
<xbl:template xxbl:transform="oxf:xslt">
<xsl:transform version="2.0">
<xsl:template match="@*|node()" priority="-100">
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
<xsl:template match="text()" priority="-100" mode="in-paragraph">
<xsl:copy>
<xsl:value-of select="."/>
</xsl:copy>
</xsl:template>
<xsl:template match="OCem" mode="in-paragraph">
<x:i><xsl:value-of select="."/></x:i>
</xsl:template>
<xsl:template match="OCp">
<x:div>
<xsl:apply-templates mode="in-paragraph"/>
</x:div>
</xsl:template>
<xsl:template match="/*">
<x:div contentEditable="true">
<xsl:apply-templates/>
</x:div>
</xsl:template>
</xsl:transform>
</xbl:template>
</xbl:binding>
</xbl:xbl>
どんな助けでも大歓迎です、
編集: tohuwawohu の有益なコメントの後 (以下) インスタンス データにバインドされる変数を定義する必要があるようです。このような:
<xsl:template match="oc:instructionitem">
<xforms:group xbl:attr="model context ref bind" xxbl:scope="outer">
<xxforms:variable name="binding" as="node()?" xxbl:scope="inner" >
<xxforms:sequence select="." xxbl:scope="outer"/>
</xxforms:variable>
<xforms:group xxbl:scope="inner">
<!-- Variable pointing to external single-node binding -->
<xforms:group ref="$binding">
<xsl:call-template name="main"/>
</xforms:group>
</xforms:group>
</xforms:group>
</xsl:template>
<xsl:template name="main">
<x:div contentEditable="true">
<xforms:repeat nodeset="*">
<xsl:call-template name="paragraph"/>
</xforms:repeat>
</x:div>
</xsl:template>
ただし、XSLT 要素は依然としてデータを操作できません。データを操作できる XFORMS 要素のみを生成できます。これは、 <xsl:template match="OCp"> のようなものが選択されないことを意味します。これが、上記のコードが名前付きテンプレートを使用する理由です。つまり、バインドされたデータを xslt コードで使用できるようにすることはできますか?
マルティン