[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Find invalid IDREFs


Subject: [xsl] Find invalid IDREFs
From: charlieo0@xxxxxxxxxxx
Date: Thu, 17 May 2012 20:42:03 +0000 (UTC)

I am completely stuck figuring this out. I have list of IDREFs captured from an error report. I created a well-formed XML instance from the list of values. This is list of IDREFs that have no corresponding ID. I need to find these IDREF atrributes in a very large collection of files and generate a report that tells writers what files the errors are located.

The validation report was generated from a concatenated, very large complete manual. I can locate the errors in that file, but that's not how the manual is worked. I need to locate each error in the sub-files.

How do I walk through the list of IDREF elements, locate them in a collection of approx. 600 files and generate a report? Any help is appreciated.

XSLT 2.0

My list of IDREFs looks like this (abbreviated):


<?xml version="1.0" encoding="UTF-8"?>
<IDREFS>
<IDREF>NSN-</IDREF>
<IDREF>NSN-</IDREF>
<IDREF>m2025792355320</IDREF>
<IDREF>m22040592355332</IDREF>
<IDREF>m22040592355332</IDREF>
<IDREF>m22040592355332</IDREF>
<IDREF>m2034792355320</IDREF>
<IDREF>m2050492355320</IDREF>
</IDREFS>

My XSLT, which renders no results:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      exclude-result-prefixes="xs"
      version="2.0">
    
   <xsl:output method="text"  omit-xml-declaration="yes" indent="no" />
   <xsl:param name="collection" select="collection('file:/M:/?select=M2*.xml')"/>
   <xsl:variable name="IDREFS" select="document('file:/C:/IDREFS.xml')"/>
    <xsl:key name="VALUE" match="IDREFS" use="child::IDREF"/>
    
    <xsl:template match="/">
        <xsl:result-document method="text" href="file:/C:/bae/test.txt">
        <xsl:for-each select="$collection//@wpid | //@itemid">
            <xsl:variable name="ATTR" select="."/>
            <xsl:for-each select="$IDREFS">
                <xsl:value-of select="base-uri(.)"/><xsl:value-of select="key('VALUE',$ATTR)"/>
            </xsl:for-each>
            <xsl:text>&#x0A;</xsl:text>
        </xsl:for-each>
    </xsl:result-document>
    </xsl:template>

</xsl:stylesheet>



C Flanders


Current Thread
Keywords