RE: [xsl] Using attributes with XPath

Subject: RE: [xsl] Using attributes with XPath
From: Mike Ferrando <mikeferrando@xxxxxxxxx>
Date: Wed, 23 Aug 2006 22:25:23 -0700 (PDT)
Jackie,
I thought I would add something else.

Attributes do not have parents. Elements can have parents, but
attributes never have parents, children, etc.

More than likely, you are not seeing the error report concerning your
XSLT. This has to do with your commandline for FOP. You should run
the XSLT against your XML separate from you PDF renderer commandline.
This will pick up your errors and let you see your XSL-FO as well.

Further, XSLT 1.0 does not allow you to write a predicate for an
attribute template/@match (well, there may be some exceptions...). At
least I have always gotten errors when I have tried to do it. (Ok, I
use SAXON 6.55 which I my XPATH statements truly love.)

This is why you are getting nothing. The templates don't make sense
and are skipped with errors (which I guess are being suppressed by
your transformation process).

Mike Ferrando
Library Technician
Library of Congress
Washington, DC
202-707-4454

--- Jacqueline Radebaugh <jrad@xxxxxxx> wrote:

> Hello:
> 
> Thank you very much for your help.  I revised my code so that I
> created two templates for the attributes of the <list> element.  It
> looks like:
> 
> <!-- list[parent::description] -->
> <xsl:template match="list[parent::description]">
> <fo:list-block>
>   <xsl:apply-templates/>
>  </fo:list-block>
> </xsl:template>
> 
> <xsl:template match="@type[parent::list]">
> <fo:inline  font-size="10pt" font-weight="normal"> 
> <xsl:apply-templates/>   
>   </fo:inline>
> </xsl:template>
> 
> <xsl:template match="@mark[parent::list]">
> <fo:inline  font-size="10pt" font-weight="normal"> 
> <xsl:apply-templates/>   
>   </fo:inline>
> </xsl:template>
> 
> <xsl:template match="item[parent::list]">
> <fo:list-item>
>  <fo:list-item-label>
>  <fo:block></fo:block>
>  </fo:list-item-label>
>  <fo:list-item-body>
>  <fo:block>
>  <xsl:apply-templates/>
>  </fo:block>
>  </fo:list-item-body>
>  </fo:list-item>
> </xsl:template>
> 
> I am still obtaining no output of the list.  However, when I take
> the attributes off of the <list> element in my source code, i.e., 
> 
> <list>
> <item>- The item contains more than one language one of which may
> be a sign language</item>
> <item>- The item is or includes a translation</item>
> <item>- The language of the summaries, abstracts, or accompanying
> material differs from the language of the main item</item>
> <item>- The language of a table of contents differs from the
> language of the main item</item>
> </list>
> 
> my XSLT code works.   What I am still doing wrong?  It is
> definitely related to the attributes of <list> (i.e., 
> type="marked" mark="*").
> 
> 
> Thank you very much for your help!
> 
> Best wishes,
> 
> 
> 
> 
> Jackie Radebaugh
> 
> Library of Congress
> Network Development & MARC Standards Office
> Washington, DC
> USA
> Phone:  +1-202-707-1153
> FAX:  +1-202-707-0115
> E-Mail:  jrad@xxxxxxx
> 
> 
> >>> mike@xxxxxxxxxxxx 08/22/06 4:27 PM >>>
> > 
> > <xsl:template match="list">
> > <fo:list-block>
> >   <xsl:apply-templates select="@* 
> 
> That will apply-templates to the attributes of the list element,
> but if
> you've written any template rules that match attributes, you
> haven't shown
> them to us.
> 
> 
> | *[contains(@type, 
> > $my_version) or string-length(@type)=0] | text()"/>  
> 
> That will match children of the list element that have a type
> attribute
> satisfying certain conditions, but in the XML you showed us, no
> children of
> the list element have a type attribute.
> 
> | text()"/>  
> 
> That will match text node children of the list element, but in the
> data you
> showed us, the only text node children of the list element were
> whitespace.
> 
> Michael Kay
> http://www.saxonica.com/ 
> 
> 


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

Current Thread