473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Possible to traverse the children of an element without specifying child element names?

Is it possible to traverse the values of children of an element, and
no need to specify
the children's element names in XSLT element?

The XML file can be

<bio>
<skills>
<languages>
<language>XML</language>
<language>Java</language>
</languages>
<databases>
<database>Oracle</database>
</databases>
</skills>
</bio>

Approach #1: This will just append all data in a sequence of strings,
not good
<UL>
<xsl:for-each select="/bio/skills">
<LI><xsl:value-of select="."/></LI>
</xsl:for-each>
</UL>

Approach #2: correct approach, but it's tedious to specify all element
names that
need to traverse
<UL>
<xsl:for-each select="/resume/skills">
<xsl:for-each select="languages/language">
<LI><xsl:value-of select="."/></LI>
</xsl:for-each>
<xsl:for-each select="databases/database">
<LI><xsl:value-of select="."/></LI>
</xsl:for-each>
</xsl:for-each>
</UL>

any ideas? please advise. thanks!!
Jul 20 '05 #1
2 1865
Matt <jr********@hotmail.com> wrote:
Is it possible to traverse the values of children of an element, and
no need to specify
the children's element names in XSLT element?

The XML file can be

<bio>
<skills>
<languages>
<language>XML</language>
<language>Java</language>
</languages>
<databases>
<database>Oracle</database>
</databases>
</skills>
</bio>


Above is input. What output do you want?

--
William Park <op**********@yahoo.ca>
Open Geometry Consulting, Toronto, Canada
Jul 20 '05 #2
jr********@hotmail.com (Matt) writes:
Is it possible to traverse the values of children of an element, and
no need to specify
the children's element names in XSLT element?

The XML file can be

<bio>
<skills>
<languages>
<language>XML</language>
<language>Java</language>
</languages>
<databases>
<database>Oracle</database>
</databases>
</skills>
</bio>
<snip>
Approach #2: correct approach, but it's tedious to specify all element
names that
need to traverse
<UL>
<xsl:for-each select="/resume/skills">
<xsl:for-each select="languages/language">
<LI><xsl:value-of select="."/></LI>
</xsl:for-each>
<xsl:for-each select="databases/database">
<LI><xsl:value-of select="."/></LI>
</xsl:for-each>
</xsl:for-each>
</UL>

any ideas? please advise. thanks!!


Does this help?

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<ul>
<xsl:for-each select="bio/skills/*/*">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</xsl:template>

</xsl:stylesheet>

--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/
Jul 20 '05 #3

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

Similar topics

15
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python suppose you want to walk into a directory, say, to apply a string replacement to all html files. The os.path.walk() rises for the occasion. © import os ©...
0
by: Ingrid | last post by:
Am I right in thinking that datatyping at element level ie <xs:element name="num" type="xs:integer"> and specifying a choice of attribute values ie <xs:attribute name="kind"> <xs:simpleType>...
39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
6
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... ...
0
by: Walt Borders | last post by:
Hi, My problem: Merging two datasets deletes parent elements, preserves all children. I've created two dataSets. Each use the same schema, parent-child nested tables. The first dataSet is...
4
by: SteveKlett | last post by:
I have a subset of form items that I need to perform different operations on (enable/disable, clear values, change style, etc) rather than hard code the IDs or names I would like to recursively...
3
by: Andrej Pavlovic | last post by:
Hi, Please look at the following HTML snippet: <body> some text <p>more text</p> even more text </body>
5
by: shapper | last post by:
Hello, I have the following list: <ul id="parent" class="parent"> <li> <img... </li> <ul id="child" class="child"> <li>Message 1</li>
6
by: gskbond | last post by:
Following is my logic to traverse level by level an mway search tree.... (Yeah I finally used templates to implement a queue... :) ) void mWayTree:: TraverseLevelOrder(Node *root,int lvl) {...
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
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.