Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 9th, 2010, 08:12 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In the XML you showed us before, the LMPResponse element was in a namespace. Now it isn't. This changes everything!
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 9th, 2010, 08:13 AM
Authorized User
 
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Sam,
I made the changes u suggested but then ErrorDetails tag are not populating.

Thanks,
divya
 
Old April 9th, 2010, 08:19 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Strange, because I ran Rummy's XSLT against your original example input XML and it gives me the exact output you asked for.

The only change I made was to add a missing closing </xsl:stylesheet> at the end of his code.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old April 9th, 2010, 08:21 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

There is a difference in namespace between your input xml and the xslt code. in the input xml you have showed the below:
Code:
<LMPResponse xmlns="http://lmps.com/lmp/webservices">
Use the same namespace in xslt code also, like the one below:
Code:
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:o="http://lmps.com/lmp/webservices"  extension-element-prefixes="soap o">
You can discard the attribute "extension-element-prefixes" from the above line.

If the above ideas does not return the needed output, then please post the current xslt code you use, with the relevant input xml.
__________________
Rummy
 
Old April 13th, 2010, 08:51 AM
Authorized User
 
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Rummy.
I am getting the output as expected.
now i have one requirement i.e

If Error count is 1 then ErrorDetails tag should have hard code attribute "TYPE=E".
LOGNAME,MODULE, PROCEDURE, SQL attributes should come from the input xml. If the Input xml doesn't have these four attributes , the output xml should have empty string .
Error Detail tag are as follows

<ErrorDetail MESSAGE=" errtext from input xml" LOGNAME="" TYPE="E" MODULE=" " PROCEDURE=" " SQL=""/>

How to define these 6 attributes in Error Details tag?

Thanks again.

divya
 
Old April 13th, 2010, 11:43 AM
Authorized User
 
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Rummy,

I tried using <xsl:attribute-set > but i got an error like "unexcepted child".
xslt used :

<xsl:if test="o:LMPResponse/o:LMPResult/o:errorCount!=0">
<xsl:attribute-set name="ErrorDetails">
<xsl:attribute name="MESSAGE"><xsl:value-of select="o:LMPResponse/o:LMPResult/o:errorInfo/@errText"/></xsl:attribute>
<xsl:attribute name="TYPE">E</xsl:attribute>
<xsl:attribute name="LOGNAME">""</xsl:attribute>
</xsl:attribute-set>
<SUCCESS> N</SUCCESS>
</xsl:if>

Could you please correct the xslt.

Thanks,
Divya.
 
Old April 13th, 2010, 11:50 AM
Authorized User
 
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Rummy,

Could you please check the xslt i wroteto get the desired output as expected. please tell whether it is good practice or not.

<xsl:if test="o:LMPResponse/o:LMPResult/o:errorCount!=0">
<ErrorDetails>
<xsl:attribute name="MESSAGE"><xsl:value-of select="o:LMPResponse/o:LMPResult/o:errorInfo/@errText"/></xsl:attribute>
<xsl:attribute name="TYPE">E</xsl:attribute>
<xsl:attribute name="LOGNAME">""</xsl:attribute>
</ErrorDetails>>
<SUCCESS> N</SUCCESS>
</xsl:if>


thanks,
divya
 
Old April 13th, 2010, 11:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>I tried using <xsl:attribute-set > but i got an error like "unexcepted child".

Divya, you desperately need a good XSLT reference book, and you need to adopt a different approach for learning the language. You can't expect to guess the way the language works and then expect people to help you when you guess wrong. You're wasting other people's time, and your own.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old April 15th, 2010, 01:13 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Divya, try with the below code:
Code:
<xsl:template match="soap:Envelope">
<xsl:apply-templates select="soap:Body"/>
</xsl:template>
 
<xsl:template match="soap:Body">
<LMPReply>
<LMPResponses>
<xsl:apply-templates select="o:LMPResponse"/>
</LMPResponses>
</LMPReply>
</xsl:template>
 
<xsl:template match="o:LMPResponse">
<LMPResponse>
<LMPReturn>
<LMPMessage>AddPortfolio <Section RowCount="0">Header</Section>
<Section RowCount="1">Details
<Row>
<xsl:apply-templates select="o:LMPResult/o:errorCount"/>
</Row>
</Section>
<Section RowCount="0">Footer</Section>
</LMPMessage>
</LMPReturn>
</LMPResponse>
</xsl:template>
 
<xsl:template match="o:LMPResult/o:errorCount">
<ErrorDetails>
<xsl:attribute name="LOGNAME"><xsl:value-of select="@LOGNAME"/></xsl:attribute>
<xsl:attribute name="MODULE"><xsl:value-of select="@MODULE"/></xsl:attribute>
<xsl:attribute name="PROCEDURE"><xsl:value-of select="@PROCEDURE"/></xsl:attribute>
<xsl:attribute name="SQL"><xsl:value-of select="@SQL"/></xsl:attribute>
<xsl:if test=". = '1'">
<xsl:attribute name="TYPE">E</xsl:attribute>
<xsl:attribute name="MESSAGE"><xsl:value-of select="../o:errorInfo/@errText"/></xsl:attribute>
<SUCCESS>N</SUCCESS>
</xsl:if>
<xsl:if test=". = '0'">
<xsl:attribute name="MESSAGE"><xsl:value-of select="../o:errorInfo/@errText"/></xsl:attribute>
<SUCCESS>Y</SUCCESS>
</xsl:if>
</ErrorDetails>
</xsl:template>
__________________
Rummy





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT:How to loop through nodes and retrieve attributes values based on some condition smandeh XSLT 2 March 24th, 2009 01:50 PM
XSLT and the if condition thisby XSLT 7 April 3rd, 2008 06:02 PM
Urgent:XSLT element value selection and condition amhicraig XSLT 1 December 4th, 2007 07:57 PM
Please help me to create XSLT condition using C# Nick2006 C# 8 July 12th, 2006 06:48 PM
Condition mateenmohd SQL Server 2000 6 May 6th, 2004 03:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.