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

Re: returning the xsl:value-of of child node of type

Subject: Re: returning the xsl:value-of of child node of type
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 18 Dec 2002 09:44:17 +0000
jeni chaffee
Hi Ryan,

> I wish to return the Value of Statuscode in the following SAML
> response example. The stylesheet I am attempting to use is below the
> xml code. I beleive my difficulty stems from the inability to
> correctly handle a namespace in the apply-templates tag.

Your XML source document has a default namespace declaration for the
namespace "urn:oasis:names:tc:SAML:1.0:protocol", which means that any
elements that don't have a prefix are in this namespace. This includes
the <Status> and <StatusCode> elements in your XML document.

When you refer to an element using XPath, you must use a prefix for
all elements that are in a namespace; without a prefix, the element
name refers to an element in *no* namespace. For example, your:

  <xsl:apply-templates select="samlp:response/Status"/>

refers to <Status> elements in no namespace, and therefore doesn't
select the <Status> element in your XML document, which is in the
"urn:oasis:names:tc:SAML:1.0:protocol" namespace.

Assuming that you have the prefix 'samlp' associated with the
"urn:oasis:names:tc:SAML:1.0:protocol" namespace, you should be using
the following code in your stylesheet:

<xsl:template match="/">
  ....
  <xsl:apply-templates select="samlp:Response/samlp:Status"/>
</xsl:template>
 
<xsl:template match="samlp:Status">
  <xsl:value-of select="samlp:StatusCode/@Value"/>
</xsl:template>

[Note the change of case for sampl:Response and that the second
template matches *all* samlp:Status elements, not just those that
appear within a samlp:Response element.]

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.