xsl-list
[Top] [All Lists]

[xsl] new: how to change value of attributes

2009-11-25 11:31:43
sorry for previous mail where equals (=) were become 3D. I don't know what's 
happened.


Hi all, i'm a librarian with a problem: i've to change the value of attribute 
for each element of a group that i'm not able to select and count.
i've something like this:

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

i have to change the value of LABEL from "pagina 5, pagina 6, pagina 7, pagina 
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 repeated.
It will be something like this:

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


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


<?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="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>


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

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


<xsl:template match="mets:div[(_at_)LABEL='Fogli di guardia 
posteriori']/mets:div">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="LABEL">
<xsl:number count="mets:div[(_at_)LABEL='Fogli di guardia 
posteriori']/mets:div" format="I"/></xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

thanks a lot to everyone.


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>