[xsl] how to change the values of a list of attribute excluding one or more of these.

Subject: [xsl] how to change the values of a list of attribute excluding one or more of these.
From: "ivanmacculi\@libero\.it" <ivanmacculi@xxxxxxxxx>
Date: Fri, 27 Nov 2009 14:40:52 +0100
Yesterday i asked you how to change the values of a enumerated list of
attributes building the string of the new values: the list is something like

<mets:div LABEL="Canto VI" ORDER="8" ORDERLABEL="1">
                    <mets:div LABEL="Pagina 56">
                        <mets:fptr FILEID="file.00059"/>
                    <mets:div LABEL="Pagina 57">
                        <mets:fptr FILEID="file.00060"/>
                    <mets:div LABEL="Pagina 58">
                        <mets:fptr FILEID="file.00061"/>
                    <mets:div LABEL="Pagina 59">
                        <mets:fptr FILEID="file.00062"/>
                    <mets:div LABEL="Pagina 60">
                        <mets:fptr FILEID="file.00063"/>
                    <mets:div LABEL="Pagina 61">
                        <mets:fptr FILEID="file.00064"/>
                    <mets:div LABEL="Pagina 62">
                        <mets:fptr FILEID="file.00065"/>
                    <mets:div LABEL="Pagina 63">
                        <mets:fptr FILEID="file.00066"/>
                    <mets:div LABEL="Pagina 64">
                        <mets:fptr FILEID="file.00067"/>
                    <mets:div LABEL="Pagina 65">
                        <mets:fptr FILEID="file.00068"/>
                    <mets:div LABEL="Pagina 66">
                        <mets:fptr FILEID="file.00069"/>

Mickael Kay suggested:

<xsl:variable name="g" select="//mets:div[matches(@LABEL, '^Pagina

<xsl:template match="*[. intersect $g]/@LABEL">
<xsl:variable name="n" select="f:index-of-node($g, .)"/>


<xsl:function name="f:index-of-node" as="xs:integer*">
<xsl:param name="nodes" as="node()*"/>
<xsl:param name="node" as="node()"/>
<xsl:for-each select="$nodes">
<xsl:sequence select="position()[current() is $node]"/>

to transform that one in this new list:

 <mets:div LABEL="Canto XI" ORDER="13" ORDERLABEL="1">
                    <mets:div LABEL="Carta [59r]" ORDER="1" ORDERLABEL="113">
                        <mets:fptr FILEID="file.00116"/>
                    <mets:div LABEL="Carta [59v]" ORDER="2" ORDERLABEL="114">
                        <mets:fptr FILEID="file.00117"/>
                    <mets:div LABEL="Carta [60r]" ORDER="3" ORDERLABEL="115">
                        <mets:fptr FILEID="file.00118"/>
                    <mets:div LABEL="Carta [60v]" ORDER="4" ORDERLABEL="116">
                        <mets:fptr FILEID="file.00119"/>
                    <mets:div LABEL="Carta [61r]" ORDER="5" ORDERLABEL="117">
                        <mets:fptr FILEID="file.00120"/>
                    <mets:div LABEL="Carta [61v]" ORDER="6" ORDERLABEL="118">
                        <mets:fptr FILEID="file.00121"/>
                    <mets:div LABEL="Carta [62r]" ORDER="7" ORDERLABEL="119">
                        <mets:fptr FILEID="file.00122"/>
                    <mets:div LABEL="Carta [62v]" ORDER="8" ORDERLABEL="120">
                        <mets:fptr FILEID="file.00123"/>
                    <mets:div LABEL="Carta [63r]" ORDER="9" ORDERLABEL="121">
                        <mets:fptr FILEID="file.00124"/>
                    <mets:div LABEL="Carta [63v]" ORDER="10"
                        <mets:fptr FILEID="file.00125"/>
                    <mets:div LABEL="Carta [64r]" ORDER="11"
                        <mets:fptr FILEID="file.00126"/>

i forgot to ask you how to exclude from the transformation the first one of
the list, in this case:

<mets:div LABEL="Pagina 59">
<mets:fptr FILEID="file.00116"/>

is it possible? thx.

Current Thread