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

UL's in XSL

Hi, bet this is simple, but so am I, so can someone help please, my
HTML is coming out wrong, as you can see from the XSL, I have <ul></ul>
in-between.

Any help would be fantastic.
---------------
I have this XML:
<Bulleted_Text apagenum="1" pagenum="1">
<Emph cstyle="Bullet">l</Emph>
text in here
</Bulleted_Text>
<Bulleted_Text apagenum="2" pagenum="2">
<Emph cstyle="Bullet">l</Emph>
text in here
</Bulleted_Text>
---------------
this XSL:
<xsl:template match="bullet">
<ul>
<li>
<xsl:apply-templates/>
</li>
</ul>
</xsl:template>
---------------
My HTML:
<ul>
<li>
text in here
</li>
<ul>
</ul>
<li>
text in here
</li>
</ul>
---------------
and want this HTML:
<ul>
<li>
text in here
</li>
<li>
text in here
</li>
</ul>

Aug 19 '05 #1
8 1075
My XSL has the wrong tag, but that was a typo in this group, so ignore
that thanks!

Aug 19 '05 #2
You're right ;-)

Your template basically says "for every "bullet", create a <li> AND
<ul>", so you should change your XSL to;

<xsl:template match="bullet">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>

then when you call your template in the main body of your XSL, add the
<ul> tags there, so that they don't repeat with every "bullet".

<ul>
<xsl:apply-templates select="bullet"/>
</ul>

Aug 19 '05 #3
Hi bit new to XSL So should it look like this?:

<xsl:template match="bullet">
<ul>
<li>
<xsl:apply-templates/>
</li>
<xsl:apply-templates select="bullet"/>
</ul>
</xsl:template>

Aug 19 '05 #4
adMjb wrote:
Hi bit new to XSL So should it look like this?:

<xsl:template match="bullet">
<ul>
<li>
<xsl:apply-templates/>
</li>
<xsl:apply-templates select="bullet"/>
</ul>
</xsl:template>


No, the <ul></ul> must be in the template for the parent of the
Bulleted_Text element, e.g.

<xsl:template match="bulletParent">
<ul>
<xsl:apply-templates select="Bulleted_Text"/>
</ul>
</xsl:template>

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Aug 19 '05 #5
Hi, the only problem is I have no bulletParent, so can't use that, all
I have is:

Example:

<root>
<para></para>
<para></para>
<bullet></ bullet>
<bullet></ bullet>
<bullet></ bullet>
<para></para>
<para></para>
</root>

So somehow I need to add <UL> befour the first and after the last
<bullet>
I.E
<root>
<para></para>
<para></para>
<ul>
<bullet></ bullet>
<bullet></ bullet>
<bullet></ bullet>
</ul>
<para></para>
<para></para>
</root>
Any ideas?

Aug 19 '05 #6
adMjb wrote:
Hi, the only problem is I have no bulletParent, so can't use that, all
I have is:


[...]

Then in template for root:
<xsl:apply-templates select="bullet[1]" mode="first"/>

and

<xsl:template match="bullet" mode="first">
<ul>
<xsl:apply-template match=". | following-sibling::bullet"/>
</ul>
</xsl:template>

<xsl:template match="bullet" mode="first">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>

Not tested.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Aug 19 '05 #7
Hi Johannes,

Thanks for you help!!, with a bit of working out I got it,

This worked:

<xsl:template match="bullet[1]">
<ul>
<xsl:apply-templates select=".|following-sibling::bullet"
mode="first"/>
</ul>
</xsl:template>

<xsl:template match="bullet" mode="first">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template match="bullet">
<xsl:text disable-output-escaping="yes"/>
</xsl:template>

Aug 19 '05 #8
Well it works on a small bit of XML but if you have this:
it groups all the <bullet> in one place :(
<root>
<text>
text here
</text>
<bullet>
a bullet
</bullet>
<bullet>
b bullet
</bullet>
<bullet>
c bullet
</bullet>
<bullet>
d bullet
</bullet>
<bullet>
e bullet
</bullet>
<text>
text here
</text>
<bullet>
e bullet
</bullet>
<bullet>
f bullet
</bullet>
</root>

Aug 19 '05 #9

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

Similar topics

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...
16
by: michael | last post by:
Is it possible to get all href URLs contained in a unordered list and place them in an array? Or in fact two different arrays, differently named one for each <ul> group? <ul> <li><a...
4
by: abs | last post by:
Anybody has an idea how to get the <ul> element which is not nested in <li> element ? In other words I have several lists like this: <ul id="1"> <li>Aaaaaaaa</li> <li>Bbbbbbbb</li>...
3
by: lawrence | last post by:
This is a follow up question to the conversation that started here: http://groups.google.com/groups?hl=en&lr=&safe=off&selm=da7e68e8.0410010901.18a813c9%40posting.google.com I tried nesting...
4
by: Japhy | last post by:
Hello, I'm am pulling data from a mysql db and want to use the data to populate a <ul. Here are relavent parts of my code : $wohdate = mysql_result($wohRS,$wohndx,woh_date); $woh_display...
4
by: Winston | last post by:
Where is the mistake? I want to make a simple menu. These are two pieces of two files... function ShowMenu(objeto) { is_open = document.getElementById(objeto).style.display;...
18
by: hendedav | last post by:
Gang, My subject is not quiet what I am looking for. I have a container div with two ul's inside. I am trying to get the two ul's to be side-by-side instead of one on top of the other. I have...
6
by: stephen.cunliffe | last post by:
Hi, I'm looking for opinion/facts/arguments on the correct nesting of UL, OL, & LI elements. For example, this is what I want (unordered list): * Item 1 * Item 2 * Item 3
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>
5
omerbutt
by: omerbutt | last post by:
hi all, i have a menu based on <ul> and <li> it is working fine on mozilla all versions IE 6 and 7 all versions and google chrome ver 2.0.172.31 , the only problem is occuring is with the IE8 here...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.