473,395 Members | 1,623 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,395 software developers and data experts.

XSL for All Values for All Nodes

I have an XML file of the form:

<AAA >
<BBB>0001</BBB>
<CCC>
<DDD>0121</DDD>
</CCC>
<DDD>
<EEE>0152</EEE>
<FFF>0032</FFF>
</DDD>
<GGG>0444</GGG>
</AAA>

What I want is

<COL>0001</COL >
<COL>0121</COL >
<COL>0152</COL >
<COL>0032</COL >
<COL>0444</COL >

What I get is

<COL>
0001

0121
0152
0032

0444
<COL>

using this Transform

<xsl:template match = "/" >
<xsl:for-each select = "/" >
<xsl:text ><COL></xsl:text>
<xsl:value-of select = "." />
<xsl:text ><COL></xsl:text>
<xsl:text > </xsl:text>
</xsl:for-each>
</xsl:template>

Shouldn't this XSL just loop for each value? And where do all those extra CRs
come from? The nodes without attributes?

Jun 5 '06 #1
3 1370


Al Hatch wrote:
<xsl:template match = "/" >
<xsl:for-each select = "/" >


I think you want
<xsl:for-each select="//text()">

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 5 '06 #2
On Mon, 5 Jun 2006 10:30:38 -0700, Martin Honnen wrote
(in article <44**********************@newsread2.arcor-online.net>):
I think you want
<xsl:for-each select="//text()">


That helps, but I still get sequences of blanks

<COL></COL>

for nodes that have no attribute.

//@* and //attribute* don't help, they also return those blanks.

How do I restrict my output to nodes that have attributes?
Jun 5 '06 #3
Al Hatch wrote:
I have an XML file of the form:

<AAA >
<BBB>0001</BBB>
<CCC>
<DDD>0121</DDD>
</CCC>
<DDD>
<EEE>0152</EEE>
<FFF>0032</FFF>
</DDD>
<GGG>0444</GGG>
</AAA>

What I want is

<COL>0001</COL >
<COL>0121</COL >
<COL>0152</COL >
<COL>0032</COL >
<COL>0444</COL >


Not tested:

<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>

<xsl:template match="*[not(*)]">
<COL>
<xsl:apply-templates/>
</COL>
</xsl:template>

<xsl:template match="*[*]">
<xsl:apply-templates select="*"/>
</xsl:template>

--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Jun 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nicolas VanOrton | last post by:
Hi all, When XercesDOMParser parses an XML document in a file, if a Schema is attached, it automatically adds all attributes with default values to the corresponding nodes... I'm trying to...
7
by: Adam Hartshorne | last post by:
As a result of a graphics based algorihtms, I have a list of indices to a set of nodes. I want to efficiently identify any node indices that are stored multiple times in the array and the...
0
by: Eric Promislow | last post by:
Has anyone else run into this? The problem is that I'm loading one schema at a time, to be displayed in a TreeView. Each node in the tree points to an item in the schema via the Tag property. ...
4
by: SteveT | last post by:
I am wanting to populate several treeviews, one for the <TRs> group and one for the <TGsgroup. Is there a simplier way to populate the Treeview than the one I did below? It seems difficult to...
2
by: riceyeh | last post by:
Hi, What does <xsl:if test="not($values)"mean? What I do not understand is $values? Here, means array? And . = $value means current node is equal to the variable value? So the total meaning is...
3
by: Ronald S. Cook | last post by:
I have a string (see below) that I want to parse out the values. As you can see, some are element-based and some are attribute-based. <METADATA version="Format5"><TITLE value="Adrenaline...
1
by: san1014 | last post by:
Hi I have a table SQL> select * from nodes; NODE_ID NODE_NAME -------------------- ------------------------------ N1 Kothhapet N2 Nagole...
0
by: Kavitha Sudhershan | last post by:
hi, i wanna read the node values from xml. As per my code i can read the node values in first child node and for the next node am not able to read the node values. pls help me. i'll paste the code...
5
bluechimera
by: bluechimera | last post by:
Of course this isn't the whole program.... but it is a rather large slice of code. Yes I am in college, I am not asking for someone to do this for me.. I think that is rather stupid... you don't...
2
by: Dahak | last post by:
It seems that my GoogleFu has failed me tonight and I'm hoping I can find some advice. I've inherited a ASP.NET project written in Visual Basic. I'm not too familiar with the .NET framework...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.