I added the code below to my customization layer to control the keeps and breaks for 
figures, informalfigures, and screenshots in paras. Now when I have:

<para> Blah <xref linkend="foo"/>.
<informalfigure>...</informalfigure>
</para>

common.xsl complains "Error: no ID for constraint linkend: foo", even though foo is 
there and the document processes fine otherwise. Looking at the xsl, a <xsl:variable 
name="targets" select="key('id',$linkend)"/> (with a corresponding <xsl:key name="id" 
match="*" use="@id"/> elsewhere) is used to determine check to see if the linkend has 
a corresponding id, but that should be fine, right? This isn't a big deal, our 
processing system validates during the build and that catches real errors, so I can 
just comment out the message, but I was curious about where I'd gone wrong :-)

Thanks,
David

  <xsl:template match="para[informalfigure or figure or screenshot]">
        <fo:block xsl:use-attribute-sets="normal.para.spacing">
          <xsl:call-template name="anchor"/>
          <xsl:call-template name="para.figure">
                <xsl:with-param name="current.nodeset">
                  <xsl:copy-of select="./* | ./text() | ./processing-instruction() | 
./comment()"/>
                </xsl:with-param>
          </xsl:call-template>
        </fo:block>
  </xsl:template>

  <xsl:template name="para.figure">

    <xsl:param name="current.nodeset"/>

    <xsl:variable name="before.figure">
      <xsl:for-each select="node()">
                <xsl:if test="
                  not(self::informalfigure) and 
                  not(self::figure) and 
                  not(self::screenshot) and 
                  not(preceding-sibling::informalfigure) and 
                  not(preceding-sibling::figure) and
                  not(preceding-sibling::screenshot)">
                  <xsl:copy-of select="current()"/>
                </xsl:if>
      </xsl:for-each>
    </xsl:variable>

    <xsl:variable name="rest">
      <xsl:for-each select="$current.nodeset/node()">
                <xsl:if test="preceding-sibling::informalfigure or
                  preceding-sibling::figure or preceding-sibling::screenshot">
                  <xsl:copy-of select="current()"/>
                </xsl:if>
      </xsl:for-each>
    </xsl:variable>

    <fo:block><!-- before.figure -->
      <xsl:apply-templates select="$before.figure/node()"/>
    </fo:block>
    <xsl:if test="
          $current.nodeset/informalfigure or
      $current.nodeset/figure or 
          $current.nodeset/screenshot">
      <fo:block  
                keep-with-previous.within-column="always" 
                keep-together.within-column="always"
                xsl:use-attribute-sets="normal.para.spacing">
                <xsl:apply-templates select="$current.nodeset/informalfigure[
              not(preceding-sibling::figure) and 
              not(preceding-sibling::informalfigure) and
                  not(preceding-sibling::screenshot)]"/>
                <xsl:apply-templates select="$current.nodeset/figure[
              not(preceding-sibling::figure) and 
              not(preceding-sibling::informalfigure) and
                  not(preceding-sibling::screenshot)]"/>
                <xsl:apply-templates select="$current.nodeset/screenshot[
              not(preceding-sibling::figure) and 
              not(preceding-sibling::informalfigure) and
                  not(preceding-sibling::screenshot)]"/>
      </fo:block>
    </xsl:if>

    <xsl:if test="normalize-space($rest) != ''">
      <xsl:call-template name="para.figure">
                <xsl:with-param name="current.nodeset" select="$rest"/>
      </xsl:call-template>
    </xsl:if>

  </xsl:template>

Reply via email to