Altova Mailing List Archives


[xsl] pulling ID or value-of inside attribute

From: Benjamin Graff <benjamin.graff@--------->
To:
Date: 12/7/2004 4:59:00 AM
Newbie question here - couldn't find something applicable in other posts...
 
I'm trying to create an <a> tag with the href attribute based partially on text and partially on a unique ID. The final output should be <a href="AQ2004_56_1_X.xml">, where X is the ID number of the article.  When I try something like...
<a> 
 <xsl:attribute name="href">
  <xsl:text>AQ2004_56_1_
  </xsl:text>
  <xsl:value-of select="article_id" />
  <xsl:text>.xml</xsl:text>
 </xsl:attribute>

...the text bits show up when the page is rendered as part of the href path, but the value-of bit with the article_id is nowhere to be found.  I've tested the value-of statement elsewhere in the document and it will pull the article_id number just fine.  I'm just trying to figure out what I'm missing - is there some reason this won't show up?

Applicable code excerpts are below from xml and xslt docs.  The "article_id" as both an attribute and an element in the xml is part of one of my earlier (not so successful) attempts at a fix.  Any help anyone could give me would be most appreciated!  Thank you.
 
***XML excerpt***
<journal>
<table_of_contents>
<article article_id="14">
  <article_id>14</article_id>
  <article_type>Book Review</article_type>
  <title>From Sit-ins to "Shirt-ins": Why Consumer Politics Matter More than Ever</title>
  <author>Kathy M. Newman</author>
  <author_institution>Carnegie Mellon University</author_institution>
  <book_reviewed>A Consumers' Republic: The Politics of Mass Consumption in Postwar America</book_reviewed>
  <book_reviewed_author>Lizabeth Cohen</book_reviewed_author>
  <print_startpage>213</print_startpage>
  <print_endpage>221</print_endpage>
 </article>
</table_of_contents>
</journal>
 
***XSLT excerpt***
<xsl:template match="journal/table_of_contents">
 
<xsl:template match="title">
<a> 
 <xsl:attribute name="href">
  <xsl:text>AQ2004_56_1_
  </xsl:text>
  <xsl:value-of select="article_id" />
  <xsl:text>.xml</xsl:text>
 </xsl:attribute>
 <xsl:attribute name="style">
  <xsl:text>
   font-size:16px;
  </xsl:text>
 </xsl:attribute>
 <xsl:value-of select="." />
</a>
</xsl:template>
 
</xsl:template>

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.