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

new: how to change the values of a list of attribute

Subject: new: 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 19:13:09 +0100
  new: how to change the values of a list of attribute
i've forgot to delete unnecessary attribute from the result XML.

so, i've this xsl file suggested by mikael kay that doesn't works to change my
xml that follows the xsl file. the result that i wolud obtain is posted to the
end.

XSL file

<?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"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:f="http://example.com/f">


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

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

    <xsl:variable name="g" select="//mets:div[matches(@LABEL, '^Pagina
        [0-9]+$')]"/>
    <xsl:template match="*[. intersect $g]/@LABEL">
        <xsl:variable name="n" select="f:index-of-node($g, ..)"/>
        <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:function name="f:index-of-node" as="xs:integer*">
        <xsl:param name="nodes" as="node()*"/>
        <xsl:param name="node" as="node()"/>
        <xsl:sequence select="1 to count($nodes)[subsequence($nodes, ., 1) is
            $node]"/>
    </xsl:function>

</xsl:stylesheet>

XML file

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

XML that i would obtain

<mets:div LABEL="Canto XI">
<mets:div LABEL="Pagina 59">
<mets:fptr FILEID="file.00116"/>
</mets:div>
<mets:div LABEL="Carta [59v]">
<mets:fptr FILEID="file.00117"/>
</mets:div>
<mets:div LABEL="Carta [60r]">
<mets:fptr FILEID="file.00118"/>
</mets:div>
<mets:div LABEL="Carta [60v]">
<mets:fptr FILEID="file.00119"/>
</mets:div>
<mets:div LABEL="Carta [61r]">
<mets:fptr FILEID="file.00120"/>
</mets:div>
<mets:div LABEL="Carta [61v]">
<mets:fptr FILEID="file.00121"/>
</mets:div>
<mets:div LABEL="Carta [62r]">
<mets:fptr FILEID="file.00122"/>
</mets:div>
<mets:div LABEL="Carta [62v]">
<mets:fptr FILEID="file.00123"/>
</mets:div>
<mets:div LABEL="Carta [63r]">
<mets:fptr FILEID="file.00124"/>
</mets:div>
<mets:div LABEL="Carta [63v]">
<mets:fptr FILEID="file.00125"/>
</mets:div>
<mets:div LABEL="Carta [64r]">
<mets:fptr FILEID="file.00126"/>
</mets:div>
</mets:div>

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.