[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Checking external files based on the attribute val
This is a bit clunky but assuming your source data is in source.xml
<?xml version="1.0"?> <doc> <graphic picfile="I970106058X_bulb"/> <graphic picfile="I970106058X_dummy"/> </doc> and your filelist is in filelist.xml <?xml version="1.0"?> <files> <file>./970106058X_c01_0002.tif</file> <file>./970106058X_c01_0001.tif</file> <file>./970106058X_bulb.tif</file> <file>./970106058X_0000.tif</file> <file>./970106058X_c01_0003.tif</file> </files> Then this seems to work. <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="files" select="document('filelist.xml')"/> <xsl:template match="/"> <doc> <xsl:apply-templates/> </doc> </xsl:template> <xsl:template match="graphic"> <xsl:variable name="file" select="substring-after(concat(@picfile,'.tif'),'I')"/> <node picfile="{@picfile}"> <xsl:attribute name="matched"> <xsl:choose> <xsl:when test="$files/files/file[contains(.,$file)]"> <xsl:value-of select="true()"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="false()"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> </node> </xsl:template> </xsl:stylesheet> peter@radish:~/xxx$ xsltproc process.xsl source.xml <?xml version="1.0"?> <doc> <node picfile="I970106058X_bulb" matched="true"/> <node picfile="I970106058X_dummy" matched="false"/> </doc> peter@radish:~/xxx$ The $files/files/file[contains(.,$file)] does not seem to want to be converted into a boolean and I couldn't construct a way of getting it to match. There has got to be a better way!
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|