472,808 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,808 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 2434
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.