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

Getting the first p inside a div

Subject: Getting the first p inside a div
From: Walter Lee Davis <waltd@xxxxxxxxxxxx>
Date: Tue, 19 Aug 2008 11:20:50 -0400
 Getting the first p inside a div
I have some footnotes in text coded like this:

<note>
	<label/>
	<cit>
		<p/>
	</cit>
	<p/>
	<p/>
</note>

While others are coded like this:

<note>
	<label/>
	<p/>
	<p/>
</note>

I have a template which grabs the label and nests it inside the first P in the note.

<xsl:template match="label[parent::note]">
<xsl:element name="a">
<xsl:for-each select="parent::note">
<xsl:attribute name="href">#c_<xsl:value-of select="@id"/></ xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@id"/></ xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
</xsl:for-each>
<xsl:text>[</xsl:text>
<xsl:apply-templates/>
<xsl:text>]</xsl:text>
</xsl:element>
<xsl:text> </xsl:text>
</xsl:template>


<xsl:template match="p[ancestor::note][1]" priority="2">
	<xsl:element name="p">
		<xsl:attribute name="class">note_p</xsl:attribute>
		<xsl:apply-templates select="ancestor::note/label"/>
		<xsl:apply-templates/>
	</xsl:element>
</xsl:template>


This works just fine, until I encounter a note coded like this:


<note>
	<label/>
	<p/>
	<cit>
		<p/>
	</cit>
</note>

Then, I end up with two copies of the same anchor, like this:

<div class="footnote">
	<p>
		<a id="foo" ... >*</a>
		Footnote here.
	</p>
	<div class="cit">
		<p>
			<a id="foo" ... >*</a>
			Citation here.
		</p>
	</div>
</div>

I am stuck using XSL 1.0 for this -- is there a way I can choke off my function after it fires the first time inside the note? Is there another way I could be looking at this problem?

Thanks,

Walter

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.