[oXygen-user] how to change value of attributes


Wed Nov 25 11:34:09 CST 2009


Sorry for my english. i will try to explain you better.
in another occasion i prepared this .xsl

<?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[@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[@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[@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[@LABEL='Testo']/mets:div[position() mod 2 = 0]" format="1"/>v]</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

</xsl:stylesheet>

in that case <mets:div LABEL="Pagina #"> was sub-element of <mets:div LABEL="testo">; instead, in this case, it's subelement of another element, like <mets:div LABEL="frontespizio". 
i need to select only <mets:div> elements that have LABEL="Pagina #", and change the value in LABEL="Carta". then i need to add a count of these elements: one count for even elements, one for odd elements. but it's difficult for me to select this group of element.




More information about the oXygen-user mailing list