 |
| 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
|
|
|
|

April 9th, 2010, 08:12 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

April 9th, 2010, 08:13 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Sam,
I made the changes u suggested but then ErrorDetails tag are not populating.
Thanks,
divya
|
|

April 9th, 2010, 08:19 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
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.
|
|

April 9th, 2010, 08:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
There is a difference in namespace between your input xml and the xslt code. in the input xml you have showed the below:
Use the same namespace in xslt code also, like the one below:
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
|
|

April 13th, 2010, 08:51 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 13th, 2010, 11:43 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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.
|
|

April 13th, 2010, 11:50 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 13th, 2010, 11:58 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
>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
|
|

April 15th, 2010, 01:13 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
|
|
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
|
|
 |