[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Trying to check if key is NOT found

Subject: Re: Trying to check if key is NOT found
From: "russurquhart1@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Dec 2014 21:23:33 -0000
Re:  Trying to check if key is NOT found
I like that! That is very elegant. I'll give that a try!

Thanks,


Russ 

 
 
 

On 12/12/14, Ihe Onwuka ihe.onwuka@xxxxxxxxx<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
 




On Fri, Dec 12, 2014 at 9:01 PM, russurquhart1@xxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

 Hi,

I have a snippet of xsl to try and look through our document xml, and let me know if a given CrossRefence href attribute does NOT contain an element with a matching Target attribute. The href attribute value is some string of characters, prefixed by a '#'. There are several elements that can have a Target attribute so i wrote my xsl like the following:

 .c9Y6TC { color:#0000ff; }.c49DIK { color:#ac306d; }.c18YC0 { color:#d00020; }.c5M9S0 { color:#000090; }.c69ORU { color:#aaaba0; } <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

 <xsl:key name="target_ref_key" match="*[@Target]" use="@Target" />

 <xsl:template match="CrossReference">

 <xsl:variable name="unhash_name" select="substring-after(@href, '#')"/>
 <xsl:variable name="matched" select="key('target_ref_key', $unhash_name)"/>
 <xsl:if test="not($matched)">
 No target for:
 <xsl:value-of select="$unhash_name"/>
 </xsl:if>

 </xsl:template>


</xsl:stylesheet>



Assuming the code above is correct why not 


<!-- for the ones that match -->
<xsl:template match="CrossReference[key('target_ref_key',substring-after(@href,'#')]">
 ....
</xsl:template


<xsl:template match="CrossReference">
 <!-- the ones that don't match will fall through to here -->
</xsl:template>

I had read some place on the web that this xsl:if would work to let me know when a key did NOT find any value, but it doesn't seem to be being called. I get the xml file as it is.

Is this the correct way to do this, or is there a better way?

thanks for any help,


Russ


XSL-List info and archive
EasyUnsubscribe(by email)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.