Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to count missing textual references using XSL

Posted on 2003-11-18
1
Medium Priority
?
277 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

688 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