This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Re:XSL for element containing mixed content.
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Re:XSL for element containing mixed content.
- From: Sandeep Deshpande <san25872 at yahoo dot com>
- Date: Sun, 9 Sep 2001 23:50:55 -0700 (PDT)
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Joerg & Yang,
Thanks for your solutions. I tried both the solutions.
<xsl:value-of select="node()"/>
<xsl:value-of select="text()"/>
Both of these solutions are working fine for the
example , which was mentioned in the mail.
<xsl:value-of select="text()[normalize-space()][1]"/>
is giving 'unknown method' error on IE5.
However I modified the same example to check if the
sentences after child elements or text in between two
child elements can also be displayed ( assuming there
can be many child elements and hence many ocurances of
mixed contents). But it was not possible to display
these sentences in the correct order.
If i introduce a new element ,say 'text', as suggested
then I have to change the DTD. ( Which probably my
client won't agree).
For e.g. (Correct & Required output )
--------------------------------------
Hi I am in a directory.
Hi I am in a subdirectory.
Hi I am in file1.
in between two files (back to subdirectory.)
Hi I am in file2.
out of file. back to subdirectory.
out of subdirectory. back to directory.
Gettting following Incorrect output on IE.
--------------------------------------
Hi I am in a directory.
Hi I am in a subdirectory.
Hi I am in file1.
Hi I am in file2.
in between two files (back to subdirectory.)
out of file. back to subdirectory.
out of subdirectory. back to directory.
(t.xml)
------------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="t.xsl"?>
<directory>
Hi I am in a directory.
<subdirectory>
Hi I am in a subdirectory.
<file>
Hi I am in file1.
</file>
in between two files (back to subdirectory.)
<file>
Hi I am in file2.
</file>
out of file. back to subdirectory.
</subdirectory>
out of subdirectory. back to directory.
</directory>
STYLESHEET (t.xsl)
------------------
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="directory">
<br/><xsl:value-of select="text()"/>
<xsl:apply-templates select="subdirectory"/>
<br/><xsl:value-of select="text()[1]"/>
</xsl:template>
<xsl:template match="subdirectory">
<html><body><font color="red">
<br/><xsl:value-of select="text()"/>
<xsl:apply-templates select="file"/>
<br/><xsl:value-of select="text()[1]"/>
<br/><xsl:value-of select="text()[2]"/>
</font></body></html>
</xsl:template>
<xsl:template match="file">
<html><body><font color="blue">
<br/><xsl:value-of select="."/></font></body></html>
</xsl:template>
</xsl:stylesheet>
- Sandeep
--- Joerg Pietschmann <joerg.pietschmann@zkb.ch>
wrote:
> "Yang" <sfyang@unisvr.net.tw> wrote
> > Sandbeep wrote:
> > >then I can write '<xsl:value-of select ".">', for
> > >directory template. But this prints all the data
> which
> > >is present in the child elements
> >
> > try <xsl:value-of select="node()"/>
>
> This wont fix it. You mean probably
> <xsl:value-of select="text()"/>
> It might be advisable to qualify the node further:
> <xsl:value-of
> select="text()[normalize-space()][1]"/>
>
> HTH
> J.Pietschmann
>
> XSL-List info and archive:
> http://www.mulberrytech.com/xsl/xsl-list
>
__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list