0

I'm still in the early stages of understanding and learning to use XBL components. I am experimenting with using a stylesheet to generate an HTML "report" on the contents of a node in the main instance (putting aside for now the issue of updating it if that node changes). I can get the stylesheet to run and generate the HTML without any values in it, but I'm still trying to understand how to get the data to the stylesheet. I looked at the "XForm Sandbox" example "xbl-xslt.xhtml", which does run in my application. That example uses an xform repeat inside the custom tag, and in the stylesheet has a template with a match referring to the custom tag, so I assume that's how the stylesheet gets its data.

I don't want it to generate any XForm markup, just HTML. On the XBL binding, I am using xxbl:mode="binding" as an attribute. I would like to just put a ref attribute on the custom tag, but I can't figure out how to pass the data to the stylesheet. (Currently in my stylesheet, everything is under a <xsl:template match="/"> element.) I noticed the "alternate table" example has this:

<xsl:template match="@*|node()">
    <xsl:copy>
         <xsl:if test="/*">
              <xsl:attribute name="xxbl:scope">outer</xsl:attribute>
         </xsl:if>
         <xsl:apply-templates select="@*[not(name() = ('style1', 'style2'))]|node()"/>
    </xsl:copy>
</xsl:template>

and this:

<xsl:template match="foo:table-alternate">
  <xh:table>
      <xsl:apply-templates select="@*|node()"/>
  </xh:table>
</xsl:template>

I imagine are the keys to this working, but how could I simply add a ref attribute on the custom tag of my xbl and have this work? I have been looking through the Orbeon documentation, the "sandbox" examples, and elsewhere, but I probably am still misunderstanding some basic principles of XBL components. Can anyone point me in the right direction?

  • I've tried to provide some context in my answer below. Just let me know if I misunderstood what you were asking about. -Alex – avernet Jul 09 '21 at 17:39

1 Answers1

0

Are you saying that you would like to pass the data in the node bound to your component to the XSLT? If so, that isn't possible, and it isn't how XSLT is expected to be used in conjunction with XBL.

Think of XSLT in XBL as macros in some other languages, as a form of meta-programming, which allows you to have code running at "form compilation time", with that code being able to generate XForms and HTML. Since it runs at "compilation time", data isn't available yet. The main language is still XForms, and in most cases, you shouldn't need to use XSLT in your XBL components.

avernet
  • 30,895
  • 44
  • 126
  • 163