473,654 Members | 3,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1377


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************ **********@news read2.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
1207
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 obtain the above behavior when adding nodes with createElementNS but I cannot do so. No default attributes are automatically added. Shouldn't it be doing so?... Here's my code for that:
7
2372
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 location of them in the array /list. Hence the output being some list of lists, containing groups of indices of the storage array that point to the same node index. This is obviously a trivial problem, but if my storage list is large and the set of...
0
1532
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. When I load the second schema, the collection of SchemaTypes.Values still contains the first schema's types. This doesn't happen when I write schemas to the console. I'm explicitly clearing the Tag property on each node in the tree before I...
4
1968
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 get to the correct DataSet values. <?xml version="1.0" encoding="utf-8" ?> <TestSample> <TRs> <TR1>
2
13690
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 "if not exists of value in array of values" ? But the result of '. = $value' is a boolean value, so '$values' should not mean "the value in values". Rice
3
2062
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 Rush"/><DESCRIPTION>Take a thrilling look at the world of skydiving and base jumping - parachuting from a building, a bridge or a cliff. With breathtaking views of skydiving over the Florida Keys, the Mojave Desert and the magnificent Fjords of Norway,...
1
3768
by: san1014 | last post by:
Hi I have a table SQL> select * from nodes; NODE_ID NODE_NAME -------------------- ------------------------------ N1 Kothhapet N2 Nagole N3 Uppal
0
1725
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 below: Sub readfile() objxmldom.async = False objxmldom.Load ("D:\CRT\rules\AQUA.xml")
5
2709
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 learn anything and if you get a job and cannot do it because someone else did the work for you.. that is your stupidity :) I understand most of this. This uses templates, that is what the <T> is... This compiles, and I can remove the head and...
2
2443
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 or XML, so bear with me. The project is about 95% complete, but the XML parser needs quite
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.