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

Correcting a prior error

Subject: Correcting a prior error
From: Dave Pawson <davep@xxxxxxxxxxxxx>
Date: Fri, 30 Jul 2010 09:44:32 +0100
 Correcting a prior error
I've been working with a series of xhtml like files, cleaning them up.
It was a case of run an identity tranform, apply corrections.
That was the theory. 
Luckily I kept a backup.
I hastily created an incorrect version of the identity transform
which omitted to copy the contents of any attributes. 

I'm left with the problem of how to correct it.
Given 
directory A contains the files to be corrected.
directory B contains the backup set of files.

I want to match on 
"x:a[not(string(@href))]" I.e. those a elements with an empty href
attribute. 

then copy across the value of the 'matching' href in the B directory,
same file. I'm iterating through the files in A using 

 <xsl:for-each select="for $f in collection('/A?select=*.xml')
                         return $f">
 <xsl:result-document 
       href="{replace(base-uri(),'A','AA')}">
       <xsl:apply-templates/>
   </xsl:result-document>
which creates the temporary directory AA with the corrections applied. 


the problem I'm finding is picking up the correct a element in 
the second file?

Having found an empty a element

I'm trying
 <xsl:variable name="backup" select="'file:///B'"/>

  <xsl:template match="x:a[not(@href)]">
    <xsl:variable name="thisdoc" select="document-uri(/)"/>
    <xsl:variable name="base"
select="substring-after($thisdoc,'blg/')"/>
    <xsl:variable name="src" select="concat($backup,'/',$base)"
as="xs:string"/>  <!- this is the basename of the filename being worked
->

<-this is an attempt to select the 'right' a element->
    <xsl:variable name="posn" select="count(ancestor::*|preceding::*)"/>
    <xsl:variable name="val" 
      select="(document($src)//*)[$posn]/@href"/>
   

    <!-- Now copy this across -->
    <x:a href="{$val}">
      <xsl:value-of select="."/>
    </x:a>
  </xsl:template>


Can anyone spot any obvious sillies please?


regards
------------------------
Dave Pawson
http://www.dpawson.co.uk
XSLT, XSL-FO and docbook FAQ



-- 

regards 

-- 
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

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.