473,698 Members | 2,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selecting subelements from a node-set

Hello all

Im having problems with selecting subelements from a dynamic created RTF
converted to a node-set:

i have hardcodet this example:

the xml structure:

<xsl:variable name="test">
<theelement>
<xsl:value-of select="'1'"></xsl:value-of>
</theelement>

<thesubelemen t>
<theelement2>
<xsl:value-of select="'1-1'"></xsl:value-of>
</theelement2>
<theelement2>
<xsl:value-of select="'1-2'"></xsl:value-of>
</theelement2>
</thesubelement>

<theelement>
<xsl:value-of select="'2'"></xsl:value-of>
</theelement>
<theelement>
<xsl:value-of select="'3'"></xsl:value-of>
</theelement>
</xsl:variable>
<xsl:variable name="XAxsisNod eSet1" select="msxsl:n ode-set($test)"/>

<xsl:for-each select="$XAxsis NodeSet1/theelement">
<xsl:value-of select="." /><br/>

<xsl:for-each select="thesube lement/theelement2">
<xsl:value-of select="." /><br/>
</xsl:for-each>

</xsl:for-each>

i would expect the result to be:
1
1-1
1-2
2
3

but my result is
1
2
3

I never interates the subelements ??? does anyone know why?? i have
tried different ways of doint this but no success?

Please help

Thomas



Jul 20 '05 #1
2 1533

"thomas" <th@dgr.dk> wrote in message
news:40******** *************@d read11.news.tel e.dk...
Hello all

Im having problems with selecting subelements from a dynamic created RTF
converted to a node-set:

i have hardcodet this example:

the xml structure:

<xsl:variable name="test">
<theelement>
<xsl:value-of select="'1'"></xsl:value-of>
</theelement>

<thesubelemen t>
<theelement2>
<xsl:value-of select="'1-1'"></xsl:value-of>
</theelement2>
<theelement2>
<xsl:value-of select="'1-2'"></xsl:value-of>
</theelement2>
</thesubelement>

<theelement>
<xsl:value-of select="'2'"></xsl:value-of>
</theelement>
<theelement>
<xsl:value-of select="'3'"></xsl:value-of>
</theelement>
</xsl:variable>
<xsl:variable name="XAxsisNod eSet1" select="msxsl:n ode-set($test)"/>

<xsl:for-each select="$XAxsis NodeSet1/theelement">
<xsl:value-of select="." /><br/>

<xsl:for-each select="thesube lement/theelement2">
<xsl:value-of select="." /><br/>
</xsl:for-each>
This last xsl:for-each instruction will not process any elements, as the
XPath expression:

thesubelement/theelement2

will not select any node.

The reason is that the "theelement " elements do not have any "thesubelem ent"
children.

If you want that a "theelement " element has a "thesubelem ent" child, then
instead of:
<theelement>
<xsl:value-of select="'1'"></xsl:value-of>
</theelement>


write:

<theelement>
<xsl:value-of select="'1'"></xsl:value-of>

<thesubelemen t>
<theelement2>
<xsl:value-of select="'1-1'"></xsl:value-of>
</theelement2>
<theelement2>
<xsl:value-of select="'1-2'"></xsl:value-of>
</theelement2>
</thesubelement>
</theelement>
Cheers,

Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #2
Thanks for your help - that was a stupid mistake!
"Dimitre Novatchev" <dn********@yah oo.com> wrote in message
news:bv******** ****@ID-152440.news.uni-berlin.de...

"thomas" <th@dgr.dk> wrote in message
news:40******** *************@d read11.news.tel e.dk...
Hello all

Im having problems with selecting subelements from a dynamic created RTF
converted to a node-set:

i have hardcodet this example:

the xml structure:

<xsl:variable name="test">
<theelement>
<xsl:value-of select="'1'"></xsl:value-of>
</theelement>

<thesubelemen t>
<theelement2>
<xsl:value-of select="'1-1'"></xsl:value-of>
</theelement2>
<theelement2>
<xsl:value-of select="'1-2'"></xsl:value-of>
</theelement2>
</thesubelement>

<theelement>
<xsl:value-of select="'2'"></xsl:value-of>
</theelement>
<theelement>
<xsl:value-of select="'3'"></xsl:value-of>
</theelement>
</xsl:variable>
<xsl:variable name="XAxsisNod eSet1" select="msxsl:n ode-set($test)"/>

<xsl:for-each select="$XAxsis NodeSet1/theelement">
<xsl:value-of select="." /><br/>

<xsl:for-each select="thesube lement/theelement2">
<xsl:value-of select="." /><br/>
</xsl:for-each>
This last xsl:for-each instruction will not process any elements, as the
XPath expression:

thesubelement/theelement2

will not select any node.

The reason is that the "theelement " elements do not have any

"thesubelem ent" children.

If you want that a "theelement " element has a "thesubelem ent" child, then
instead of:
> <theelement>
> <xsl:value-of select="'1'"></xsl:value-of>
> </theelement>


write:

<theelement>
<xsl:value-of select="'1'"></xsl:value-of>

<thesubelemen t>
<theelement2>
<xsl:value-of select="'1-1'"></xsl:value-of>
</theelement2>
<theelement2>
<xsl:value-of select="'1-2'"></xsl:value-of>
</theelement2>
</thesubelement>
</theelement>
Cheers,

Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html

Jul 20 '05 #3

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

Similar topics

1
1696
by: Tjerk Wolterink | last post by:
Hello all, I've written an XML file that looks a bit like this: <a> <space:b> content 1 </space:b> <b> content 2
1
1085
by: dizzyhaze | last post by:
Here is a sample of the kind of XML I'm working with: <root> <elemt>Something is ro<lig>tt</lig>en in the state of <emph>Den</emph>mark</elemt> </root> I would like to be able to extract the contents of <elemt> as a string without the subelements and with the integrity of the words unaffected...for example:
1
1585
by: Nancy Shelley | last post by:
Hi all: I am building a navigation menu using telerik's rad treeview I am able to build the outer menu but not the children. How do I select the child nodes (item) from within the loop? Any help would be greatly appreciated!! Dim node As XmlNode For Each node In xmlDoc.SelectNodes("/configuration/groups/group/menus/menu")
2
1484
by: Saurabh Sharma | last post by:
Hi, I am using Dom Parsing in Xml. I am the parent node and it has many children and each children has many children. I want to select children with a given name . Is there any method by which we select them with not going to each child node .. something like node.selectnodes (* + "/ABC"); I have time constraint and also i have to do changes so have to use DOM
0
937
by: Daniel Jorge | last post by:
Hi there, I'm in need to create a WebControl with subelements, just like ListBox, DropDownlList and stuff. But, of course, it's myh custom Item and not a ListItem control. The final result should be like this one (HTML / Design-time) <myNamespace:myControl id="myControl"> <myNamespace:myItem property1="teste" property2="teste1" ></myItem> <myNamespace:myItem property1="teste" property2="teste2" ></myItem>
2
7494
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView nodes. The TreeView populates dynamically as there are a significant number of nodes. The DataGrid displays both the items and the nodes from the TreeView. Using the explorer analogy this means the TreeView shows folders, and the DataGrid folders...
4
3700
by: visu | last post by:
I need a solution to my problem. the problem is I ll have a button in page ... and when i click it .. content of a div tag has to be get selected (i.e what we normally do with mouse to selecting some part of a page).. then i can do CTRl+C to copy the selected div content.. to paste it in MS Word or in any other external application..
0
1185
by: Satiz | last post by:
Hi All, I've a TreeView(IE Webcontrol) and a DataGrid in my VS.Net 2003 ASP.Net web form. My problem : If i select a particular node(it may be parent, child or leaf), then the corresponding values from a dataTable should be displayed in the DataGrid. I've a code-behind function for LoadGrid(), this is calling selecting a node and clicking a button only, I want to load grid while selecting a node. Pls give me the codes and ideas to do, it's...
7
4738
by: Thomas Schmidt | last post by:
Hi all, I need an XPath which selects all nodes of a specific name which start with a text node, i.e. I want the expression to select: <x> abcdefg <y>hijklmn</y> </x>
1
1725
by: DeveloperX | last post by:
Hi, I should probably start with my XML as it makes it easier to explain the problem. <?xml version="1.0" encoding="utf-8" ?> <aa note="top level"> <b1 note="b1"> <c1 note="b1 c1"> <d1 note="b1 c1 d1" />
0
9155
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...
1
8890
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8858
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
7711
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...
1
6517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4360
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2322
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
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.