Subject: Re: [xsl] returning the xsl:value-of of child node of type From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Wed, 18 Dec 2002 09:44:17 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] returning the xsl:value-o, David Carlisle | Thread | [xsl] ANN: XPath Explorer Release 2, Alex Chaffee / Purpl |
RE: [xsl] [ANN] <oXygen/> XML Edito, Cams Ismael | Date | RE: [xsl] combining two variables t, Michael Kay |
Month |