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

preceding axis is too permissive for my stylesheet

Subject: preceding axis is too permissive for my stylesheet
From: "Tony Zanella" <tony.zanella@xxxxxxxxx>
Date: Sat, 31 May 2008 19:22:56 -0400
 preceding axis is too permissive for my stylesheet
xsl processor: Saxon 8B
xsl version 2.0

Here is my test case:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <div1><!--Article-->
        <ptr target="ids.27.3.1fm" n="10"/>
        <ptr target="ids.27.3.2fm" n="11"/>
        <div2><!--Subsection-->
            <ptr target="ids.27.3.3fm" n="12"/>
            <ptr target="ids.27.3.4fm" n="13"/>
        </div2>
        <div2><!--Notes-->
            <ptr target="ids.27.3.1tm" n="10"/>
            <ptr target="ids.27.3.2tm" n="11"/>
            <ptr target="ids.27.3.3tm" n="12"/>
            <ptr target="ids.27.3.4tm" n="13"/>
        </div2>
    </div1>
    <div1><!--Article-->
        <ptr target="ids.27.3.3fm" n="14"/>
        <ptr target="ids.27.3.4fm" n="15"/>
        <div2><!--Notes-->
            <ptr target="ids.27.3.3tm" n="14"/>
            <ptr target="ids.27.3.4tm" n="15"/>
        </div2>
    </div1>
    <test><ptr/></test>
</root>

Here's my stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="xml" indent="no" encoding="utf-8" media-type="text/xml"
        doctype-public="-//TEI P4//DTD Main Document Type//EN"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template
match="ptr[matches(@target,'([a-z]{3})\.([0-9]+)\.([0-9s]+)\.([0-9]+)[tf]m+?')]">
        <xsl:choose>
            <xsl:when
test="matches(@target,'([a-z]{3})\.([0-9]+)\.([0-9s]+)\.([0-9]+)[f]m+?')">
                <ptr target="{@target}" n="{count(.|preceding::ptr)}"/>
            </xsl:when>
            <xsl:otherwise>
                <ptr target="{@target}" n="{count(.|preceding-sibling::ptr)}"/>
            </xsl:otherwise>
        </xsl:choose>

    </xsl:template>


For my output, I get:

<?xml version="1.0" encoding="utf-8"?><root>
    <div1><!--Article-->
        <ptr target="ids.27.3.1fm" n="1"/>
        <ptr target="ids.27.3.2fm" n="2"/>
        <div2><!--Subsection-->
            <ptr target="ids.27.3.3fm" n="3"/>
            <ptr target="ids.27.3.4fm" n="4"/>
        </div2>
        <div2><!--Notes-->
            <ptr target="ids.27.3.1tm" n="1"/>
            <ptr target="ids.27.3.2tm" n="2"/>
            <ptr target="ids.27.3.3tm" n="3"/>
            <ptr target="ids.27.3.4tm" n="4"/>
        </div2>
    </div1>
    <div1><!--Article-->
        <ptr target="ids.27.3.3fm" n="9"/>
        <ptr target="ids.27.3.4fm" n="10"/>
        <div2><!--Notes-->
            <ptr target="ids.27.3.3tm" n="1"/>
            <ptr target="ids.27.3.4tm" n="2"/>
        </div2>
    </div1>
    <test><ptr/></test>

This not quite what I want. In the second <div1>, I want the first two
@n values to be "1" and then "2", to match the markers in "Notes". The
preceding axis is too permissive, and preceding-sibling doesn't get me
there either, since for what I want, it doesn't track how @target
values with an "fm" in them are nested. I'm stumped. Any suggestions?
This list has been a great resource for me. I really appreciate your
help and attention!
Tony

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.