[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

need to parse last 3 characters before .jpg

Subject: need to parse last 3 characters before .jpg
From: "Geoff Krajeski" <GKrajeski@xxxxxxxxxxx>
Date: Fri, 12 Sep 2008 13:27:10 -0400
 need to parse last 3 characters before .jpg
I'm trying to parse the last three characters to determine the image
size I need for a bunch of image nodes of varying sizes. I have the
following nodes and need to get the one with the sqm.jpg.  My xsl is
below.  Not sure where to go from here...


<feed>
	<contest>
		<title>Win a Commodore 128!</title>

<link>http://dev.taunton.com/contest/win-a-commodore-128</link>
		<items>
			<item>
				<images>
				<image size="_sqs"
src="http://dev.taunton.com/assets/uploads/posts/3529/quilt_full1_lg_sqs
.jpg" />
				<image size="_sqm"
src="http://dev.taunton.com/assets/uploads/posts/3529/quilt_full1_lg_sqm
.jpg" />
				<image size="_sql"
src="http://dev.taunton.com/assets/uploads/posts/3529/quilt_full1_lg_sql
.jpg" />
				<image size="_lg"
src="http://dev.taunton.com/assets/uploads/posts/3529/quilt_full1_lg_lg.
jpg" />
				<image size="_xl"
src="http://dev.taunton.com/assets/uploads/posts/3529/quilt_full1_lg_xl.
jpg" />
			  </images>
			  <title>vote for me you chump</title>
			  <member>phunkphuz7</member>
			  <date>Tue, 09 Sep 2008 22:07:30 -0400</date>

			  <description><![CDATA[seriously, it would mean
an awful lot to me.]]></description>

<link>http://dev.taunton.com/item/3529/vote-for-me-you-chump</link>
			</item>
			<item>
				<images>
				<image size="_sqs"
src="http://dev.taunton.com/assets/uploads/posts/3538/cs-v5-cat-sewing_s
qs.JPG" />
				<image size="_sqm"
src="http://dev.taunton.com/assets/uploads/posts/3538/cs-v5-cat-sewing_s
qm.JPG" />
				<image size="_sql"
src="http://dev.taunton.com/assets/uploads/posts/3538/cs-v5-cat-sewing_s
ql.JPG" />
				<image size="_lg"
src="http://dev.taunton.com/assets/uploads/posts/3538/cs-v5-cat-sewing_l
g.JPG" />
				<image size="_xl"
src="http://dev.taunton.com/assets/uploads/posts/3538/cs-v5-cat-sewing_x
l.JPG" />
			  </images>
			  <title>my entry</title>
			  <member>phunkphuz14</member>
			  <date>Tue, 09 Sep 2008 22:01:44 -0400</date>
			  <description><![CDATA[is this
working?]]></description>

<link>http://dev.taunton.com/item/3538/my-entry</link>
			</item>
	</contest>
</feed>

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:contest="http://itsstagefuture.taunton.com/finewoodworking/usercon
trols/xsl">
<xsl:output method="html" version="1.0" encoding="iso-8859-1"
indent="yes"/>
  <!-- Root template -->
  <xsl:template match="feed/contest">
    <html>
      <head>
        <title>Fine Woodworking - <xsl:value-of select="title" /> Most
Recent Posts</title>

		<style type="text/css">
			body { margin: 0; padding: 0; }
			.item { width: 189px; height: 289px; float:
left; background:
url(http://dev.taunton.com/assets/images/background_feed_contest_item.pn
g) 0 0 no-repeat; padding: 20px; }
		</style>
      </head>

      <!-- Body -->
      <body>
		<h1>Check out the most recent entries</h1>
		<a><xsl:attribute name="href"><xsl:value-of
select="link" /></xsl:attribute>View All Entries</a>
		<!-- Logo -->
		<xsl:for-each select="items/item">
			<div class="item">
				<xsl:for-each select="images/image">
					<!--<xsl:value-of select="@src"
/>-->
					<!-- need sqm image -->
					<xsl:value-of
select="substring-before(@src,'.jpg')" /><br/>
					<xsl:value-of
select="substring-after(@src,'_')" />
					<!--<xsl:value-of
select="string-length(substring-before(@src,'.jpg')" />-->
					  	<img><xsl:attribute
name="src"><xsl:value-of select="@src" /></xsl:attribute><xsl:attribute
name="alt"><xsl:value-of select="parent::node()/parent::node()/title"
/></xsl:attribute></img>
				</xsl:for-each>
				<a><xsl:attribute
name="href"><xsl:value-of select="link" /></xsl:attribute><xsl:value-of
select="title" /></a><br/>
			</div>
		</xsl:for-each>
      </body>

    </html>
  </xsl:template>
  <xsl:template match="image">
  	<img><xsl:attribute name="src"><xsl:value-of select="@src"
/></xsl:attribute></img>
  </xsl:template>

</xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.