Solved

How to count missing textual references using XSL

Posted on 2003-11-18
1
222 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now