Solved

How to count missing textual references using XSL

Posted on 2003-11-18
1
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

737 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