[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|