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

how to create an exclusion list from a variable?

Subject: how to create an exclusion list from a variable?
From: "ivanmacculi\@libero\.it" <ivanmacculi@xxxxxxxxx>
Date: Fri, 27 Nov 2009 21:00:23 +0100
 how to create an exclusion list from a variable?
HI all, i've this xml and i'm tryng to change the value of the attributes.
This is what i have:

<mets:div LABEL="Canto I">
                    <mets:div LABEL="Pagina 7">
                        <mets:fptr FILEID="file.00010"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 8">
                        <mets:fptr FILEID="file.00011"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 9">
                        <mets:fptr FILEID="file.00012"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 10">
                        <mets:fptr FILEID="file.00013"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 11">
                        <mets:fptr FILEID="file.00014"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 12">
                        <mets:fptr FILEID="file.00015"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 13">
                        <mets:fptr FILEID="file.00016"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 14">
                        <mets:fptr FILEID="file.00017"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 15">
                        <mets:fptr FILEID="file.00018"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 16">
                        <mets:fptr FILEID="file.00019"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 17">
                        <mets:fptr FILEID="file.00020"/>
                    </mets:div>
                </mets:div>

this is what i would like to obtain:

<mets:div LABEL="Canto I">
                    <mets:div LABEL="Pagina 7">
                        <mets:fptr FILEID="file.00010"/>
                    </mets:div>
                    <mets:div LABEL="Carta [1r]">
                        <mets:fptr FILEID="file.00011"/>
                    </mets:div>
                    <mets:div LABEL="Carta [1v]">
                        <mets:fptr FILEID="file.00012"/>
                    </mets:div>
                    <mets:div LABEL="Carta [2r]">
                        <mets:fptr FILEID="file.00013"/>
                    </mets:div>
                    <mets:div LABEL="Carta [2v]">
                        <mets:fptr FILEID="file.00014"/>
                    </mets:div>
                    <mets:div LABEL="Carta [3r]">
                        <mets:fptr FILEID="file.00015"/>
                    </mets:div>
                    <mets:div LABEL="Pagina 13">
                        <mets:fptr FILEID="file.00016"/>
                    </mets:div>
                    <mets:div LABEL="Carta [3v]">
                        <mets:fptr FILEID="file.00017"/>
                    </mets:div>
                    <mets:div LABEL="Carta [4r]">
                        <mets:fptr FILEID="file.00018"/>
                    </mets:div>
                    <mets:div LABEL="Carta [4v]">
                        <mets:fptr FILEID="file.00019"/>
                    </mets:div>
                    <mets:div LABEL="Carta [5r]">
                        <mets:fptr FILEID="file.00020"/>
                    </mets:div>
                </mets:div>

Hannon helped me to create this xsl that trasforms the values of all the
attributes (Michael Kay suggested me another way to do it, but it's difficult
to me to use it -he uses functions and namespaces- and it doesn't work), but,
now, i need to exclude some of these, in this case "Pagina 7" and "Pagina 13".
How can i build an exclusion list in the variable? thank you a lot to
everyone. i promise i will start to study Kay's manual early, and disturbing
no more.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="#all" version="2.0"
xmlns:mets="http://www.loc.gov/METS/"	xmlns:mix="http://www.loc.gov/mix/"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:rd="http://cosimo.stanford.edu/sdr/metsrights/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output indent="yes" method="xml"/>

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

        <xsl:template match="mets:div/@LABEL[matches(., '^Pagina [0-9]+$')]">
            <xsl:variable name="n">
                <xsl:number level="any" count="mets:div[@LABEL[matches(.,
                    '^Pagina [0-9]+$')]]"/>
            </xsl:variable>
            <xsl:attribute name="LABEL" select="concat('Carta [', if ($n mod 2
=
                0) then concat(($n + 1) idiv 2, 'v]') else concat(($n + 1)
idiv 2, 'r]'))"/>
        </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-2011 All Rights Reserved.