473,396 Members | 2,050 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,396 software developers and data experts.

XSLT - selecting for <div> but not <table>

How do I select all <div> tags except those which contain a <table> tag
somewhere within them?

Example XML:

<********************** sample input ***********************>

<txtSectionBody>
<div>
<span>
Text Content
</span>
</div>
<div>
<span>
<table>
<tbody vAlign="top">
<tr>
<td>
<div>
<font style="FONT-SIZE: 11pt" size="+
0">
<strong>Dose (mg)</strong>
</font>
</div>
</td>
</tr>
<tr>
<td>
<div>
<font style="FONT-SIZE: 11pt">
250
</font>
</div>
</td>
</tr>
</tbody>
</table>
</span>
</div>
<div>
<font face="undefined">
<span style="FONT-SIZE: 11pt">Various text content</span>
</font>
</div>
<div>
<font face="undefined">
<span style="FONT-SIZE: 11pt">More text content</span>
</font>
</div>
</txtSectionBody>

</********************** sample input ***********************>

Which I need to transform to
<text>
<paragraph>
Text content
</paragraph>
<table>
<tr>
<td>Dose (mg)</td>
</tr>
<tr>
<td>250</td>
</tr>
</table>
<paragraph>
Various text content
</paragraph>
<paragraph>
More text content
</paragraph>
</text>

So I need to select out the div's that *don't* wrap a table and transform
them to paragraph tags, then grab the table out of the div tag and put it
as a child of the document.

I'm trying this:
<text>
<xsl:for-each select="txtSectionBody">
<xsl:for-each select="xhtml:div[not(self::table)]">
<paragraph>
<xsl:value-of select="."/>
</paragraph>
</xsl:for-each>
<xsl:for-each select="xhtml:div/span/table">
<table>
<xsl:for-each select="tbody/tr">
<tr>
<xsl:for-each select="td">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</xsl:for-each>
</text>

Help?

Philo
(email is first name, middle initial "j", last name. Remove the last name
to reply)
Jul 20 '05 #1
1 2469
In article <Xn********************************@216.196.105.13 0>,
Philo <ph**************@microsoft.com> wrote:
How do I select all <div> tags except those which contain a <table> tag
somewhere within them?


div[count(.//table) = 0]

-- Richard
Jul 20 '05 #2

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

Similar topics

3
by: Paul Thompson | last post by:
When I put a <div ...> inside a <table> specification, functionality is not there. When I put the <table> inside the <div> everything works. Why is that?
1
by: Alan Hoyle | last post by:
I was using a <table border> to generate borders around some info/images, and decided to follow the w3c guidelines and convert it to CSS boxes with borders since it wasn't really tabular data. ...
7
by: Herbman | last post by:
Hi, I'm trying to position a <tr> ("row") element with CSS. The table itself is positioned with <div> tags. The problem is when I use <div> tags to position the rows within the table nothing...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
1
by: Sean | last post by:
I have a table (with tabular data) that I want to display on a webpage. Initially the talbe is empty. When a user clicks on a button, a child window opens up with a form and some text fields. ...
4
by: He Shiming | last post by:
Hi, I'm wondering how can I use <DIV> to mimic a <TABLE>. In a bare <TABLE> without a width attribute, the width of the table get dynamically expanded according to the content. However, <DIV>...
10
by: neverquit | last post by:
hi , Iam Nagesh,Begineer in using Ajax,well i have been using ajax in application, i have faced a problem while placing the responseTEXT into the <div> tag positioned inside the <form> tag iam...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.