aspose file tools*
The moose likes Product and Other Certifications and the fly likes concat() function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "concat() function" Watch "concat() function" New topic
Author

concat() function

Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
Hi,
Is this a correct syntax to concat values.
<xsl:value-of select="concat(/item/description, ' is the description of part number ', /item/part-number)"/>
for this xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="order.xsl"?>
<order number="312597">
<date>2000/1/1</date>
<!-- this is the customer A-->
<customer id="216A">Company A</customer>
<item>
<part-number warehouse="Warehouse 11">E16-25A</part-number>
<description>Production-class widget</description>
<quantity>16</quantity>
</item>
<!-- this is the customer B-->
<customer id="216B">Company B</customer>
<item>
<part-number warehouse="Warehouse 12">E16-25B</part-number>
<description>Production-class widgetA</description>
<quantity>20</quantity>
</item>
</order>
Thanks
Shoba
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
Looks OK.
Does the output you get look like Production-class widget is the description of part number E16-25A?
[ May 06, 2002: Message edited by: John Wetherbie ]

The only reason for time is so that everything doesn't happen all at once.
- Buckaroo Banzai
Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
Hi,
I'm not getting the expected results. My output is just "is the description of part-number".
Thanks
Shoba
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
Hmm...
Prior to calling the value-of with the concat are you sure that your context node is an order element? If you were in the wrong location that could explain the problem.
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
OK, the problem is with the / before item. If you are in an order element node (template-match="order") then the value-of element should look like this:

If you are in the root node (template-match="/") then do this:
Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
Hi JOhn,
No, It is not working.My xsl file is
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="/order/customer[@id='216B']">
<xsl:value-of select="concat(item/description, ' is the description of part number ',item/part-number)"/><br></br>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Thanks
Shoba
John Wetherbie
Rancher

Joined: Apr 05, 2000
Posts: 1449
Remember from the other thread that you can use .. to get to the parent node. I would try placing ../ in from of item and see if that doesn't do the trick.
Srikanth Vrudhula
Greenhorn

Joined: Apr 25, 2002
Posts: 14
Hi Shoba,
Your xml file is wrong. If you want the desired output, your xml file should be like this

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="order1.xsl"?>
<order number="312597">
<date>2000/1/1</date>
<!-- this is the customer A-->
<customer id="216A">Company A
<item>
<part-number warehouse="Warehouse 11">E16-25A</part-number>
<description>Production-class widget</description>
<quantity>16</quantity>
</item>
</customer>
<!-- this is the customer B-->
<customer id="216B">Company B
<item>
<part-number warehouse="Warehouse 12">E16-25B</part-number>
<description>Production-class widgetA</description>
<quantity>20</quantity>
</item>
</customer>
</order>
The problem is with your <customer> element. There is no loop in the <customer> element and your calling <xsl:for-each select="/order/customer[@id='216B']">, in your xml file. I have rectified the error. Please check it.
Thnx
Srikanth
divine India Ltd
Mail Id: srikanth.vrudhula@divine.com
Rakesh Gudur
Ranch Hand

Joined: Apr 29, 2002
Posts: 79
Hi Shobha,
As specified by Srikanth, the <Item> tag should be a child of <Customer> which is not the case with your xml file. The XML file provided by srikanth will clear the error.
reg,
Rakesh.
Software Eng, HYD.
Shoba Ramachandran
Ranch Hand

Joined: Mar 29, 2001
Posts: 68
Oh, What a silly mistake...
Thanks very much guys for correcting me.
Thanks
Shoba
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: concat() function