[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Renaming processing instructions
A PI in the source file: <?dbfo bgimage="myfile.jpg"?> Extracting the value: <xsl:variable name="bgroundimage"> <xsl:call-template name="dbfo-attribute"> <xsl:with-param name="pis" select="ancestor-or-self::d:abstract/processing-instruction('dbfo')"/> <xsl:with-param name="attribute" select="bgimage"/> </xsl:call-template> </xsl:variable> <xsl:variable name="backgroundimg"> <xsl:value-of select="concat('url(', $bgroundimage, ')')"/> </xsl:variable> and further down, using the value for an output attribute: <xsl:attribute name="background-image"> <xsl:value-of select="$backgroundimg"/> </xsl:attribute> Bob Stayton Sagehill Enterprises bobs@sagehill.net From: Xmplar Sent: Tuesday, October 30, 2012 3:11 AM To: docbook-apps@lists.oasis-open.org Subject: [docbook-apps] Renaming processing instructionsI have managed to (mostly) achieve the PIs I need, but I'd like to know if it's possible to rename PIs to shorten the amount of text.
In the XML I have: <abstract><?dbfo background-image="images/Box5-4.gif" background-position="0% 30%" ex:background-content-width="60mm"?>
<title>Chapter 1 overview</title> ...My customization so far needs to use those long names ("background-image", etc.). Can I somehow rename these to, say, "bgimage" instead of "background-image"?
My customization is: <xsl:template match="d:abstract" mode="chapter.titlepage.recto.auto.mode"> <xsl:variable name="bgroundimage"> <xsl:call-template name="dbfo-attribute"> <xsl:with-param name="pis" select="ancestor-or-self::d:abstract/processing-instruction('dbfo')"/> <xsl:with-param name="attribute" select="'background-image'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="backgroundimg"> <xsl:value-of select="concat('url(', $bgroundimage, ')')"/> </xsl:variable> <xsl:variable name="bgroundwidth"> <xsl:call-template name="dbfo-attribute"> <xsl:with-param name="pis" select="ancestor-or-self::d:abstract/processing-instruction('dbfo')"/><xsl:with-param name="attribute" select="'ex:background-content-width'"/>
</xsl:call-template> </xsl:variable> <xsl:variable name="bgroundposition"> <xsl:call-template name="dbfo-attribute"> <xsl:with-param name="pis" select="ancestor-or-self::d:abstract/processing-instruction('dbfo')"/> <xsl:with-param name="attribute" select="'background-position'"/> </xsl:call-template> </xsl:variable> <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ex="http://www.renderx.com/XSL/Extensions" xsl:use-attribute-sets="chapsummaryprops"> <xsl:if test="processing-instruction()"> <xsl:attribute name="background-image"> <xsl:value-of select="$backgroundimg"/> </xsl:attribute> <xsl:attribute name="ex:background-content-width"> <xsl:value-of select="$bgroundwidth"/> </xsl:attribute> <xsl:attribute name="background-position"> <xsl:value-of select="$bgroundposition"/> </xsl:attribute> </xsl:if> <xsl:apply-templates select="d:title" /> <xsl:apply-templates select="d:para" /> </fo:block> </xsl:template> Thanks, On 29-10-12 10:35 PM, Xmplar wrote:I'm trying to create a custom processing instruction to insert and format a background image in a chapter abstract. I've followed the instructions in Chapter 9 of DocBook XSL TDG but am getting error messages about empty parameters.
The XML is: <abstract> <?dbfo bgimage="images/Box5-4.gif"?> <?dbfo bgposition="50% 30%"?> <?dbfo bgwidth="170mm"?> <title>Chapter 1 overview</title> <para>The text in . </para> </abstract> </info> (I'd like to combine all three params into one pi if possible.) I've set up variables for background-image, content-width and position: <xsl:template match="d:abstract" mode="chapter.titlepage.recto.auto.mode"> <xsl:variable name="bgimage"> <xsl:call-template name="dbfo-attribute"> <xsl:with-param name="pis" select="ancestor-or-self::d:abstract/processing-instruction('dbfo')"/> <xsl:with-param name="attribute" select="'background-image'"/> </xsl:call-template> </xsl:variable> <xsl:variable name="bgwidth"> <xsl:call-template name="dbfo-attribute"> <xsl:with-param name="pis" select="ancestor-or-self::d:abstract/processing-instruction('dbfo')"/><xsl:with-param name="attribute" select="'ex:background-content-width'"/>
</xsl:call-template> </xsl:variable> <xsl:variable name="bgposition"> <xsl:call-template name="dbfo-attribute"> <xsl:with-param name="pis" select="ancestor-or-self::d:abstract/processing-instruction('dbfo')"/> <xsl:with-param name="attribute" select="'background-position'"/> </xsl:call-template> </xsl:variable> <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:ex="http://www.renderx.com/XSL/Extensions" xsl:use-attribute-sets="chapsummaryprops" background-image="{$bgimage}" ex:background-content-width="{$bgwidth}" background-position="{$bgposition}"> <xsl:apply-templates select="d:title" /> <xsl:apply-templates select="d:para" /><!--<xsl:apply-templates select="." mode="chapter.titlepage.recto.mode"/>-->
</fo:block> </xsl:template> And when I process it with Saxon 6.5.5 the error messages are:[warning] Attribute 'background-image' cannot have a value of "": should be either 'inherit' or a URI: background-image="url(...)". [error] Attribute 'rx:background-content-width' cannot have a value of "".
I'm using DB 1.77.1, XEP 4.19. Thanks --Dave Gardiner
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]