xsl-list
[Top] [All Lists]

RE: [xsl] Adding a border to graphics

2007-10-30 08:15:54
Hi, Michael.

The only thing I try to do actually, is to customize
the "image.processing" template in graphics.xsl by
adding the following part:
<fo:external-graphic>
    <xsl:if test="ancestor::figure[role|@bordered]">
    <xsl:attribute
name="border-color">black</xsl:attribute>
<xsl:attribute
name="border-style">solid</xsl:attribute>
</xsl:if>
</fo:external-graphic>

I import graphics,xsl into my customization layer and
add the piece above as I have already described.
Apparently, -:( I do it in a wrong fashion.

please, help!

Thanks in advance,
nancy

--- Michael Kay <mike(_at_)saxonica(_dot_)com> wrote:


When you say "it didn't work", you mean it didn't do
what you expected it to
do: so to deal with your problem I have to look at
your incorrect code and
try and work out what you thought it might do.

Sorry if I'm guessing wrong, but you seem to be
imagining that when you
write an <imagedata> element to the result tree, the
template with
match="imagedata" is going to magically involved to
post-process it, and
perhaps that the output of this template is going to
magically replace the
element that was matched in the tree. If so, then
I'm afraid you're guilty
of wishful thinking!

There are many ways you could tackle this problem,
but the one that's
closest to your design is to write the <imagedata>
element to a variable,
and then call apply-templates on this variable. You
can then have two
variants ot the template that process this element
(one of which might do
nothing). Note that to apply templates to a
temporary tree you either need
XSLT 2.0, or a 1.0 processor with the xx:node-set()
extension.

Michael Kay
http://www.saxonica.com/


So I did two things:

1) in my template for bordered images I inserted a
"role" 
attribute with value "bordered" like that:

<xsl:template match="diagram_border">
<xsl:element name="figure">
    <xsl:attribute name="id">
      <xsl:value-of select="@ref"/>
    </xsl:attribute>
    <xsl:attribute name="role">
    <xsl:value-of select="@bordered"/>
    </xsl:attribute>            
    <title>
      <xsl:value-of select="@t"/>
    </title>
    <mediaobject>
      <imageobject>
        <xsl:element name="imagedata">
          <xsl:attribute
name="width">80%</xsl:attribute>
          <xsl:attribute
name="scalefit">1</xsl:attribute>
          <xsl:attribute name="fileref">
      <xsl:value-of select="concat('images/', @ref,
'.png')"/>
          </xsl:attribute>
        </xsl:element>
      </imageobject>
    </mediaobject>
  </xsl:element>
</xsl:template>


2) I added the following in the customization
layer:

<xsl:template match="imagedata">
<fo:external-graphic>
    <xsl:if
test="ancestor::figure[role|@bordered]">
    <xsl:attribute
name="border-color">black</xsl:attribute>
    <xsl:attribute
name="border-style">solid</xsl:attribute>
    </xsl:if>
</fo:external-graphic>
</xsl:template>

However, it does not work. Please, advise!

Thanks in advance,
Nancy


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam
protection around 
http://mail.yahoo.com 



--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--