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

Re: Omit TEIForm and capture attributes of current nod

Subject: Re: Omit TEIForm and capture attributes of current node
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 25 Sep 2008 11:57:13 -0400
Re:  Omit TEIForm and capture attributes of current nod
J.S.,

At 01:31 AM 9/25/2008, you wrote:
XSL
<xsl:template match="p">
<xsl:for-each-group select="node()" group-adjacent="self::list self::figure[@id]">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<xsl:apply-templates select="self::*"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="@rend">
<p class="{@rend}">
<xsl:copy-of select="current-group()"/>
</p>
</xsl:if>
<xsl:if test="not(@rend)">
<p><xsl:copy-of select="current-group()"/></p>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>

A couple of problems here:


* Starting from the context inside for-each-group, "@rend" will not select the @rend attribute from the matched p element. Rather, the path would be "../@rend" or "parent::p/@rend". (Also there's a typo in the group-adjacent expression.)

* The group-adjacent expression isn't going to work. You need an expression that will return a single atomic value for each node in the group. Presumably, the expression you want will give one value for lists and figures with IDs (putting adjacent ones into groups), another value for all other nodes (putting adjacent ones into groups).

Then too, other improvements are also possible.

<xsl:template match="p">
<xsl:variable name="p" select="."/>
<xsl:for-each-group select="node()" group-adjacent="exists(self::list | self::figure[@id])">
<xsl:choose>
<xsl:when test="current-grouping-key()">
<xsl:apply-templates select="current-group()"/>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:copy-of select="$p/@rend"/>
<xsl:copy-of select="current-group()"/>
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>


The instruction <xsl:copy-of select="$p/@rend"/> will copy any @rend attribute on the p, but it will not create @rend attributes where there are none. (The variable here is only to make it clearer what is going on: "../@rend" would also work.)

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

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.