Subject: Re: [xsl] Find invalid IDREFs From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 17 May 2012 17:10:21 -0400 |
<xsl:key name="item-by-idrefs" match="*[@idrefs]" use="tokenize(@idrefs,'\s+')"/>
<xsl:template match="IDREFS"> <xsl:apply-templates select="key('item-by-idrefs',IDREF)"/> </xsl:template>
Cheers, Wendell
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>
</xsl:text> </xsl:for-each> </xsl:result-document> </xsl:template>
</xsl:stylesheet>
-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Find invalid IDREFs, charlieo0 | Thread | [xsl] Finding the closest preceding, mlcook |
[xsl] Find invalid IDREFs, charlieo0 | Date | [xsl] Finding the closest preceding, mlcook |
Month |