473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help in XSLT, Get multiple values instead of one per loop

how can i convert the following XML
__________________________________________________
<?xml version="1.0" encoding="UTF-8"?>
<object type="company" action="C">
<property name="howmanynumbers" action="Create">
<value>1</value>
<value>2</value>
<value>3</value>
</property>
<property name="howmanynumbers" action="Delete">
<value>a</value>
<value>b</value>
<value>c</value>
</property>
<property name="numbers" action="Update">
<value>123456</value>
<value>234567</value>
</property>
</object>
__________________________________________________ ______

when iam using the XSLT i prepared something like this
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match = "/">
<xsl:element name="Header">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>

<xsl:template match ="object">
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
<xsl:value-of select="@type"/>
<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

<xsl:element name="action">
<xsl:value-of select="@action"/>
</xsl:element>
<xsl:apply-templates select = "property" />
<xsl:apply-templates select = "object" />
<xsl:text disable-output-escaping="yes">&lt;/</xsl:text>
<xsl:value-of select ="@type"/>
<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
</xsl:template>

<xsl:template match = "property">
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

<xsl:element name="action">
<xsl:value-of select="@action"/>
</xsl:element>
<xsl:element name="value">
<xsl:value-of select="value"/>
</xsl:element>

<xsl:text disable-output-escaping="yes" >&lt;/</xsl:text>
<xsl:value-of select="@name"/>
<xsl:text disable-output-escaping="yes"> &gt; </xsl:text>

</xsl:template>
</xsl:stylesheet>

Iam getting the o/p like dis....

<?xml version="1.0" encoding="UTF-16"?><Header><company><action>C</action><howmanynumbers><action>Create</action><value>1</value></howmanynumbers > <howmanynumbers><action>Delete</action><value>a</value></howmanynumbers > <numbers><action>Update</action><value>123456</value></numbers > </company></Header>


But the value is not repeated only the first value in each property it is giving can anyone suggest the modification in stylesheet so that i will get the full output like dis
<howmanynumbers><value>1</value><value>2</value><value>3</value><action>Delete</action></howmanynumbers >

Thanks in advance
KuttanKuttan
Feb 22 '08 #1
2 5761
jkmyoung
2,057 Expert 2GB
Replace
<xsl:element name="value">
<xsl:value-of select="value"/>
</xsl:element>

with
<xsl:copy-of select="value"/>
Feb 22 '08 #2
thanks a lot its working fine :)
Feb 23 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax:...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
6
by: utterberg | last post by:
Hi, I've got an xml that looks like this: <section name="Risk"> <label>RISK MANAGEMENT (RM)</label> <field name="RM.1"> <ref>RM.1</ref> <label>Text goes here...</label> <option...
8
by: drose0927 | last post by:
Please help! I can't get my program to exit if the user hits the Escape button: When I tried exit(EXIT_SUCCESS), it wouldn't compile and gave me this error: Parse Error, expecting `'}''...
5
by: Patrick.O.Ige | last post by:
I have an xml and i'm trying to loop each node... When i do FOR EACH i seem not to get my desired result I want to loop through and get only the values that matches the question i specified with...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
4
by: Iain | last post by:
Hi all, I am try to split the some data out of a nested xml file and get all the data in one new xml file. I have two XSLT files one takes the personal information and one takes the data out of...
9
by: dan | last post by:
within a loop i am building a sql insert statement to run against my (programatically created) mdb. it works but it seems unreasonably SLOW! Sorry, dont have the code here but the jist is very...
2
Dormilich
by: Dormilich | last post by:
Hi, I'm testing my classes for a web page and I stumble upon an error I don't have a clue what it means: Error: Fatal error: Can't use method return value in write context in "output.php" on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.