xsl-list
[Top] [All Lists]

RE: How to parse user input?

2005-01-03 17:31:43
thanks - i'll take a closer look at the attribute - class.

-----Original Message-----
From: Pieter Reint Siegers Kort 
[mailto:pieter(_dot_)siegers(_at_)elnorte(_dot_)com]
Sent: Monday, January 03, 2005 2:57 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] How to parse user input?


Hi Tiffany,

Don't know what your exact xml and xslt is at the moment but the following
may help you:

Input XML (assumed):
<root>
<p class="last">
<p>this is what the user inputs</p>
<img src="images/arrowRight.gif" alt="" width="8" height="8" title=""/>
</p>
</root>

Input XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

<xsl:output method="html" omit-xml-declaration="yes"/>

<xsl:template match="/root">
<html>
<body>
<xsl:apply-templates select="p"/>
</body>
</html>
</xsl:template>

<xsl:template match="p">
<xsl:choose>
<xsl:when test="@class">
<p class="last">
<xsl:apply-templates select="p"/>
<img src="/public/images/arrowRight.gif" alt="" width="8" height="8"
title="">
</img>
</p>
</xsl:when>
<xsl:otherwise>
 <xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>

Output generated using Xslerator 2.6 using MSXML 4.0:
<html>
<body>
<p class="last">this is what the user inputs<img
src="/public/images/arrowRight.gif" alt="" width="8" height="8"
title=""></p>
</body>
</html>

It is based on the test at <xsl:when test="@class"> where the test returns
true if the sttribute 'class' is present, otherwise it returns false.

HTH,
<prs/>

-----Original Message-----
From: Tiffany Blake [mailto:Tiffany_Blake(_at_)gap(_dot_)com] 
Sent: Monday, January 03, 2005 4:15 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] How to parse user input?

i have an xml file where the user inputs content, but the xml automatically
embeds paragraph tags around the content.

        <p>this is what the user inputs</p>

then when my presentation file transforms it, an extra pair of paragraph
tags is generated as a result, which causes the gif file to appear on a
separate line:

        <p class="last"><p>this is what the user inputs</p><img
src="images/arrowRight.gif" alt="" width="8" height="8" title=""></p>

xsl used:

<p class="last"><xsl:apply-templates select="user_input"/>
                <img src="/public/images/arrowRight.gif" alt="" width="8"
height="8" title=""></img> </p>

how do i parse the only text the user input, stripping the <p> tags to get
the desired result?  do i then need to concatenate with the gif file?

desired result:

        <p class="last">this is what the user inputs<img
src="images/arrowRight.gif" alt="" width="8" height="8" title=""></p>

thanks for your help,
tiffany_blake(_at_)gap(_dot_)com


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>