docbook-apps

  • 1.  Using XSL parameter inside XSL attribute?

    Posted 02-12-2020 16:26

    Hi,

    it's not directly a DocBook question but because I'm creating an XSL-FO
    transformation for a DocBook documentation my question kind of fits in
    here...

    The transformation chain is as follows:

    - Starting a transformation batch file with a parameter via command line
    - "transf.bat bar"

    - The batch file calls Saxon, handing over a parameter
    - [several Saxon options] foo=bar [other parameters]

    - The Saxon uses my docbook_custom.xsl

    - In the docbook_custom.xsl I'm declaring a parameter
    - <xsl:param name="foo"/>.

    This parameter handover works so far.

    If I want the value of this parameter used as content e.g. in a
    fo:block, this would be realised like this:

    <fo:block>
    Parameter: <xsl:value-of select = "$foo" />
    </fo:block>

    "transf.bat test" will result in "Parameter: test" somewhere in the
    document after the transformation.

    So far so good.

    But I'm looking for a way to use the parameter $foo as part of an fo
    attribute, e.g.:

    <fo:external-graphic src="url('images/logo_###.svg')" />

    where "###" is the value of the parameter $foo.

    When calling "transf.bat basic" the transformation should use the image
    logo_basic.svg.

    The <xsl:value-of select = "$foo" /> don't want to be used inside
    attributes, or I didn't find the solution yet...

    Is there a convenient way to realise this.

    I would be grateful for tips or alternatives.

    Cheers from Aachen, Germany
    Michael







  • 2.  Re: Using XSL parameter inside XSL attribute?

    Posted 02-12-2020 17:18

    Hi,

    me again. Just cut the Gordian knot...

    The solution is actually quite simple by using the <xsl:value-of> inside
    <xsl:attribute>:

    <fo:external-graphic>
    <xsl:attribute name="some_att">some_value</xsl:attribute>
    <xsl:attribute name="src">url('images/logo_<xsl:value-of select="$foo"
    />.svg')</xsl:attribute>
    </fo:external-graphic>

    HTH.

    Cheers from Aachen
    Michael





  • 3.  Re: Using XSL parameter inside XSL attribute?

    Posted 05-26-2020 10:53
    On 12.2.2020 17:26, oasis@docbook-autor.de wrote:
    > But I'm looking for a way to use the parameter $foo as part of an fo
    > attribute, e.g.:
    >
    > <fo:external-graphic src="url('images/logo_###.svg')" />
    >
    > where "###" is the value of the parameter $foo.

    You can use attribute value template for this -- curly braces have
    special meaning inside attributes:

    <fo:external-graphic src="url('images/logo_{$foo}.svg')" />

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML and Web consulting and training services
    DocBook/DITA customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------