[thelist] XSL position()=last() adding ID to div

0 8 0112358 at gmail.com
Wed Aug 30 09:40:02 CDT 2006


The problem is probably Firefox, not your code.  The two files below
work for me in IE and in XMLSpy's Browser view, which uses IE.

Hope this helps.

--
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<root>
	<div>This is my first div element.</div>
	<div>This is my second div element.</div>
	<div>This is my third div element.</div>
	<div>This is my fourth div element.</div>
</root>
--
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="no" encoding="iso-8859-1"/>

<xsl:template match="/"><xsl:apply-templates /></xsl:template>
<xsl:template match="div"><p><xsl:apply-templates /></p></xsl:template>
<xsl:template match="div[position() = last()]"><p
style="font-weight:bold"><xsl:apply-templates /></p></xsl:template>

</xsl:stylesheet>





On 8/29/06, Greg <user at example.net> wrote:
> >
> > Not sure I follow what you mean when you say that you "browse the xml file."
> >
> > If you're running the XSL snippet only when transforming to HTML, why
> > would anything be in the XML file?
> >
> > On 8/28/06, Greg <user at example.net> wrote:
> >
> >> > I'm testing for the last element, then adding ID to that last div.
> >> >
> >> > If I transform the xml to html file all is well.
> >> >
> >> > But if I browse the xml file, that last id is missing from the
> >> > interpreted file.
> >> > Frustrating to a newbie, any clues?
> >> >
> >> > (Oh, I'm using XmlSpy)
> >> >
> Rather than transform the xml to static html, I intended (perhaps
> naively) to view all the data pages 'live', by including a ref to the
> xslt stylesheet in the xml files, then use FF to view the site
> documents. (The site was not originally intended for general external
> use - more for a SIG user to download)
>
> Noticed that my last wrap wasn't working. Viewed the generated source
> (in FF) and 'surprise' the modified div wasn't modified!, so I generated
> a static version - using the same stylesheet - and the modified div
> appears as expected. ??
>
> Greg
>
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>



More information about the thelist mailing list