Answered by:
xslt map issue

Question
-
Hi ,
any one help me , i need add one text to map for each output .
as per need add sample, befor generating output.
as per script my generate wrong out put
<xsl:template name ="tText">
<xsl:param name="paramone"/>
<xsl:variable name="text2" select="$paramone"/>
<xsl:if test="$paramone !=''">
<xsl:element name="ghf" >
<xsl:value-of select="concat('sample',$text2)"/>
</xsl:element>
</xsl:if>input file:
<F>
<S>
<a >sample1</a>
<a >sample2</a>
</s>
</F>
output:
i want output like : samplesample1
sample2
wrong ouput : sample sample1
sample sample2Saturday, October 18, 2014 5:52 PM
Answers
-
Hi Aniraos,
If your input is in this format
<Root>
<S>
<a>Sample1</a>
<a>Sample2</a>
</S>
</Root>
try using this below inline xslt template in scripting functoid and assign it to the destination field
<xsl:template name="sample">
<xsl:template name ="sample"> <xsl:for-each select="xpath of element a"> <xsl:element name="S"> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </xsl:template>
ur output will b something like this
<Sample>
<S>Sample1</S>
<S>Sample2</S>
</Sample>
Monday, October 20, 2014 6:43 AM
All replies
-
Your sample input is not valid XML! The closing tag </s> does not match the opening tag <S>.
If you use the following input:
<F> <S> <a>sample1</a> <a>sample2</a> </S> </F>
And apply the following custom XSLT:
<?xml version="1.0" encoding="utf-16"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" xmlns:int="http://atea.com/schemas/v10" exclude-result-prefixes="xsl int var" version="1.0"> <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" /> <xsl:template match="F"> <sample> <xsl:for-each select="S/a"> <xsl:element name="{.}" /> </xsl:for-each> </sample> </xsl:template> </xsl:stylesheet>
You get the following output:
<sample> <sample1 /> <sample2 /> </sample>
If however you want this output (I'm not sure by your description):
<sample> <ghf>sample1</ghf> <ghf>sample2</ghf> </sample>
You can use this custom XSLT:
<?xml version="1.0" encoding="utf-16"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" xmlns:int="http://atea.com/schemas/v10" exclude-result-prefixes="xsl int var" version="1.0"> <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" /> <xsl:template match="F"> <sample> <xsl:for-each select="S/a"> <ghf> <xsl:value-of select="." /> </ghf> </xsl:for-each> </sample> </xsl:template> </xsl:stylesheet>
Morten la Cour
Sunday, October 19, 2014 10:28 AM -
Thanks for reply , but we want out put like : we have pass text like below
sample:
sample1 sample2
- Edited by anilraos Monday, October 20, 2014 4:11 AM
Monday, October 20, 2014 4:09 AM -
Hi Aniraos,
If your input is in this format
<Root>
<S>
<a>Sample1</a>
<a>Sample2</a>
</S>
</Root>
try using this below inline xslt template in scripting functoid and assign it to the destination field
<xsl:template name="sample">
<xsl:template name ="sample"> <xsl:for-each select="xpath of element a"> <xsl:element name="S"> <xsl:value-of select="."/> </xsl:element> </xsl:for-each> </xsl:template>
ur output will b something like this
<Sample>
<S>Sample1</S>
<S>Sample2</S>
</Sample>
Monday, October 20, 2014 6:43 AM -
U will have to have a flat file schema for the same and use the flat file assembler in send pipeline and u will get the text message out.
Regards <br/> When you see answers and helpful posts,<br/> please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
Monday, October 20, 2014 8:02 AMAnswerer -
U can use word concat or other way is
<xsl:template name ="tText">
<xsl:param name="paramone"/><xsl:param name="sample1"/>
<xsl:param name="sample2"/>
<xsl:variable name="text2" select="$paramone"/>
<xsl:if test="$paramone !=''">
<xsl:element name="ghf" >
<xsl:value-of select="$sample1"/><xsl:value-of select="$sample2"/>
</xsl:element>
</xsl:if>- Proposed as answer by BizTLearner Monday, October 20, 2014 2:37 PM
Monday, October 20, 2014 2:37 PM