← Prev in month ← Prev in thread

Renaming processing instructions

From
Xmplar <>
Date
2012-10-30T10:11:24+00:00
ID
Thread
Renaming processing instructions
I 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:
    
      
      
      
  X-NONE
  X-NONE
  
   
   
   
   
   
   
   
   
   
   
   
  
  MicrosoftInternetExplorer4
  
   
   
   
   
   
   
   
   
   
   
   
  

      
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
← Prev in month ← Prev in thread