Solved

How to count missing textual references using XSL

Posted on 2003-11-18
1
247 Views
Last Modified: 2006-11-17
If I have an XML document as follows:

<info>
   <books>
       <book name="Book1" />
       <book name="Book2" />
       <book name="Book3" />
       <book name="Book4" />
       <book name="Book5" />
       <book name="Book6" />
   </books>

   <quotes>
      <quote from="Book1" />
      <quote from="Book13" />
      <quote from="Book4 />
      <quote from="Book2" />
   </quotes>
</info>

How can I get a count of the //quotes/quote items where there is no corresponding //books/book (using the @from as a pivot against the @name)?

I'm sure it's something to do with xsl:key but can't get anything to work.  The source-data is hand-coded and a schema will not suffice... it's not illegal (in my real-world case) for the data to be missing, I simply need to know how many are missing....

Thanks.
Ray
0
Comment
Question by:ray_hayes
1 Comment
 
LVL 9

Accepted Solution

by:
sparkplug earned 500 total points
ID: 9770100
You could do it in one XPath statement as follows:

<xsl:value-of select="count(/info/quotes/quote[not(@from = /info/books/book/@name)])"/>

>S'Plug<
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question