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

How to check if a node has no children with XSLT

3
Hello!
I need some help figuring out an XPath expression that can go in the match of this template to only match with nodes that have no children. I've tried a couple different things, but am drawing blanks. Here is the snippet of the code that is dealing with this issue:
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="<!---- HELP -->">
  2.       <tr class="data_row">
  3.           <td"><xsl:value-of select="@name" /></td>
  4.           <td><xsl:value-of select="@qty" /></td>
  5.           <td><xsl:value-of select="@total-sales" /></td>
  6.           <td><xsl:value-of select="@cog" /></td>
  7.           <td><xsl:value-of select="@profit" /></td>
  8.           <td><xsl:value-of select="@gross-margin" /></td>
  9.       </tr>
  10.       <xsl:apply-templates>
  11.               <xsl:sort select="@profit" order="descending" data-type="number"/>
  12.       </xsl:apply-templates>
  13.  
Thanks in advance for the help!
Jul 12 '07 #1
4 40594
Dököll
2,364 Expert 2GB
Hello!
I need some help figuring out an XPath expression that can go in the match of this template to only match with nodes that have no children. I've tried a couple different things, but am drawing blanks. Here is the snippet of the code that is dealing with this issue:
[HTML]
<xsl:template match="<!---- HELP -->">
<tr class="data_row">
<td"><xsl:value-of select="@name" /></td>
<td><xsl:value-of select="@qty" /></td>
<td><xsl:value-of select="@total-sales" /></td>
<td><xsl:value-of select="@cog" /></td>
<td><xsl:value-of select="@profit" /></td>
<td><xsl:value-of select="@gross-margin" /></td>
</tr>
<xsl:apply-templates>
<xsl:sort select="@profit" order="descending" data-type="number"/>
</xsl:apply-templates>
[/HTML]

Thanks in advance for the help!
May I refer you to this site for the time being? http://www.w3schools.com/xpath/xpath_nodes.asp. I could be adding other sites of interest. Please let us know if you found helpful...
Jul 12 '07 #2
joshk
3
May I refer you to this site for the time being? http://www.w3schools.com/xpath/xpath_nodes.asp. I could be adding other sites of interest. Please let us know if you found helpful...
Thank you for suggesting that link. However, I already read up on the W3schools tutorials on both xslt and xpath and still have been unable to discern the appropriate way to match a node with no children. Any other suggestions?
Jul 12 '07 #3
jkmyoung
2,057 Expert 2GB
not(node())

Or if you just want no child elements,
not(*)

So an element node without child elements is:
*[not(*)]
Jul 12 '07 #4
joshk
3
not(node())

Or if you just want no child elements,
not(*)

So an element node without child elements is:
*[not(*)]
Perfect. Thanks so much for your help in solving this one!
Jul 12 '07 #5

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

Similar topics

3
by: Michael Reiche | last post by:
Question on XSL expression Got this XML: <Body> <Page> <Line no="9" detail="true"> <onefield>onefieldstext</onefield> <twofield>twofieldstext</twofield> </Line>
4
by: titanandrews | last post by:
Hi, I have ran into a situation that I think should be possible, but I am fairly new to XSLT so maybe not. Suppose I have the following document <ROOT> <FOO name="A"> <CHILD name="B"/>...
2
by: DaRik | last post by:
Hi, I'm having some difficulties with a menu I'm making. I build up the menu through DOM. I append childnodes to a tree. 2 types of children are possible: url (a hyperlink) and sub (a submap). ...
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... ...
5
by: Adam Sandler | last post by:
Hello, I have a treeview with a node where the children are read/populated directly from a database. Some of the text which comes from this database isn't always user friendly. I'd like to...
1
by: saurcurban | last post by:
Hi, Following is the xml file: ------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <wc> Delhi is the capital of India
2
by: skipbr | last post by:
Lets just say I have this xml dynamically generated. <test> <itemA> <item>084</item> </itemA> <itemA> <item>085</item> </itemA> <itemB> <item>100</item>
1
by: Nougatti | last post by:
Hi, I am trying to remove part of an xml file using xslt. The output should be an exact copy of the input, but one node should be removed based on an attribute value. for instance: <AAA> ...
5
by: njsimha | last post by:
Hi, In the folowing XML snippet: <template1> <name>student</name> <elem1> <subelem1>65</subelem1> <subelem2>15</subelem2> </elem1>
1
by: jpjpjpjp | last post by:
Hi All, I just started working with XSLT, so this question might be obvios for some; i'm struggling trying to concatenate 2 tags inside the same node. I will be receiving one XML file and my...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.