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

Re: xsl

Subject: Re: xsl
From: "CyberSpace Industries 2000 Inc." <csi2000@xxxxxxxxxxxxxxx>
Date: Wed, 3 May 2006 11:29:08 -0400
xsl soap
Indira... Your problem is that your xslt only has a single template matching on the node "Idresult" (which has two child nodes "Userid" and "Username").

You could access these by using <xsl:value-of select="UserID" /> and <xsl:value-of select="Username" /> where the XPath
in both of these mean child of Idresult.


The XPATH statements you do use have element names in them that do not exist in your XML.... hence the select statements return nothing.

For example - <xsl:value-of select="LogonAndGetLogByAuthenticationIdResponse/LogonAndGetLogByAuthenticationIdResult/UserId"/>

says you want to select the node called "Userid" that is a child of "LogonAndGetLogByAuthenticationIdResult" which in
turn is a child of "LogonAndGetLogByAuthenticationIdResponse" that is a child of your 'current node' IDresult. These do not exist in your XML.


The string you do get out is the result of the default templates kicking in - since you do not have any templates for
the root node, soap:Envelope, soap:Body or IdResponse .


Remember that the XSLT processor will read in your xml document, form up an in-memory tree of nodes (starting at the root element - with a single child node (your document node soap:Envelope)

    /(root)
         |
soap:Element
         |
soap:body
         |
Idresponse
         |
  IDresult
         | ------------------------|
UserID                        Username
         |                              |
text( ) 'hello'                 text( ) 'there'



It will traverse that tree of nodes - and at each node determine whether or not you provided a template to handle that node. If not, default templates will be invoked - the result being the concatentated values of all descendent text nodes being returned - in your case 'hellothere'.

Cheers...Hugh
CyberSpace Industries 2000 Inc.
XML Training and Consulting

----- Original Message ----- From: "Indira Hoti" <IHoti@xxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, May 03, 2006 10:47 AM
Subject: xsl



Hi all,



I haven't got much experience with XML and I just came across a code,
like the one below, which uses 'soap: Envelope' to encapsulate data.

My problem is in getting the xsl file to display that info. At the
moment with the xsl code below I can extract some information, but its
dsisplayed in one string or line, rather than assigned to a html table
cell. Any suggestions would be appreciated. Thanks J



Regards,

Indira



-----------xml-------------------------------------------------

<?xml version="1.0" encoding="utf-8"?>

<?xml-stylesheet type="text/xsl" href="response.xsl"?>



<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Body>

<IdResponse

xmlns="http://kkkk.com/DDiii">

<IdResult>



<UserId>hello</UserId>

<Username>there</Username>



</IdResult>

</IdResponse>

</soap:Body>

</soap:Envelope>

-----------------------------------------------------------------



--------------------xsl------------------------------------------

<?xml version='1.0'?>

<xsl:stylesheet

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns="http://directdebit.com/DDLog"

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

version="1.0">



<xsl:template match="soap:Envelope/soap:Body/IdResponse/IdResult">

<HTML>

<BODY>

  <table BORDER="0" align="center" width="750px" height="70px"
bgcolor="#ffffff">

<TR >

<TD colspan="5" width="47%" height="20px">

<span > User Id: </span>

      <xsl:value-of
select="LogonAndGetLogByAuthenticationIdResponse/LogonAndGetLogByAuthent
icationIdResult/UserId"/>

</TD>

</TR>

<TR >

<TD colspan="5" width="47%" height="20px">

<span> User name: </span>

     <xsl:value-of
select="LogonAndGetLogByAuthenticationIdResponse/LogonAndGetLogByAuthent
icationIdResult/Username "/>

</TD>

</TR>

</table>

</BODY>

</HTML>

</xsl:template>

</xsl:stylesheet>



------output I get----------------------------



hellothere

Current Thread
  • xsl
    • Indira Hoti - 3 May 2006 14:47:39 -0000
      • Jon Gorman - 3 May 2006 15:16:46 -0000
      • CyberSpace Industries 2000 Inc. - 3 May 2006 15:29:25 -0000 <=
      • Michael Kay - 3 May 2006 15:30:08 -0000

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.