Solved

How to count missing textual references using XSL

Posted on 2003-11-18
1
273 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

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.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

635 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