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

how to change value of attributes

Subject: how to change value of attributes
From: "ivanmacculi\@libero\.it" <ivanmacculi@xxxxxxxxx>
Date: Wed, 25 Nov 2009 17:26:06 +0100
 how to change value of attributes
Hi all, i'm a librarian with a problem: i've to change the value of attri=
bute for each element of a group that i'm not able to select and count.
i've something like this:

<mets:div LABEL=3D"Testo" ORDER=3D"4" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Frontespizio" ORDER=3D"1" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Pagina 5" ORDER=3D"1" ORDERLABEL=3D"5">
<mets:fptr FILEID=3D"file.00008"/>
</mets:div>
</mets:div>
<mets:div LABEL=3D"Dedica" ORDER=3D"2" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Pagina 6" ORDER=3D"1" ORDERLABEL=3D"6">
<mets:fptr FILEID=3D"file.00009"/>
</mets:div>
</mets:div>
<mets:div LABEL=3D"Canto I" ORDER=3D"3" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Pagina 7" ORDER=3D"1" ORDERLABEL=3D"7">
<mets:fptr FILEID=3D"file.00010"/>
</mets:div>
<mets:div LABEL=3D"Pagina 8" ORDER=3D"2" ORDERLABEL=3D"8">
<mets:fptr FILEID=3D"file.00011"/>
</mets:div>
<mets:div LABEL=3D"Pagina 9" ORDER=3D"3" ORDERLABEL=3D"9">
<mets:fptr FILEID=3D"file.00012"/>
</mets:div>
</mets:div>
</mets:div>

i have to change the value of LABEL from "pagina 5, pagina 6, pagina 7, p=
agina 8, etc..." to "carta 1r, carta 1v, carta 2r, carta 2v, etc".
So the problem is that i've a order of pages with a kind of enumeration, =
and it will became a list of a double enumeration. each number is repeate=
d.
It will be something like this:

<mets:div LABEL=3D"Testo" ORDER=3D"4" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Frontespizio" ORDER=3D"1" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Carta 1r" ORDER=3D"1" ORDERLABEL=3D"5">
<mets:fptr FILEID=3D"file.00008"/>
</mets:div>
</mets:div>
<mets:div LABEL=3D"Dedica" ORDER=3D"2" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Carta 1v" ORDER=3D"1" ORDERLABEL=3D"6">
<mets:fptr FILEID=3D"file.00009"/>
</mets:div>
</mets:div>
<mets:div LABEL=3D"Canto I" ORDER=3D"3" ORDERLABEL=3D"1">
<mets:div LABEL=3D"Carta 2r" ORDER=3D"1" ORDERLABEL=3D"7">
<mets:fptr FILEID=3D"file.00010"/>
</mets:div>
<mets:div LABEL=3D"Carta 2v" ORDER=3D"2" ORDERLABEL=3D"8">
<mets:fptr FILEID=3D"file.00011"/>
</mets:div>
<mets:div LABEL=3D"Carta 3r" ORDER=3D"3" ORDERLABEL=3D"9">
<mets:fptr FILEID=3D"file.00012"/>
</mets:div>
</mets:div>
</mets:div>


in another occasion i prepared this .xsl, but in that case <mets:div LABE=
L=3D"Pagina #"> was subelement of text and not subelement of another elem=
ent. so this's my problem.


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


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

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


<xsl:template match=3D"mets:div[@LABEL=3D'Testo']/mets:div[position() mod=
2 =3D 1]">
<xsl:copy>
<xsl:apply-templates select=3D"@*"/>
<xsl:attribute name=3D"LABEL">
<xsl:text>Carta [</xsl:text><xsl:number count=3D"mets:div[@LABEL=3D'Testo=
']/mets:div[position() mod 2 =3D 1]" format=3D"1"/>r]</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match=3D"mets:div[@LABEL=3D'Testo']/mets:div[position() mod=
2 =3D 0]">
<xsl:copy>
<xsl:apply-templates select=3D"@*"/>
<xsl:attribute name=3D"LABEL">
<xsl:text>Carta [</xsl:text><xsl:number count=3D"mets:div[@LABEL=3D'Testo=
']/mets:div[position() mod 2 =3D 0]" format=3D"1"/>v]</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


<xsl:template match=3D"mets:div[@LABEL=3D'Fogli di guardia posteriori']/m=
ets:div">
<xsl:copy>
<xsl:apply-templates select=3D"@*"/>
<xsl:attribute name=3D"LABEL">
<xsl:number count=3D"mets:div[@LABEL=3D'Fogli di guardia posteriori']/met=
s:div" format=3D"I"/></xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

thanks a lot to everyone.

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.