Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Preceding sibling selction

From: Senthilukvelaan <skumaravelan@-------------->
To:
Date: 3/3/2009 6:37:00 PM
Hi ,
I have tried the same using the below style sheet.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:template match="/">
		<html>
			<body>
				<table>
		<xsl:call-template name="text"></xsl:call-template>
		<xsl:call-template name="html"></xsl:call-template>
				</table>
			</body>
		</html>
	</xsl:template>
<xsl:template name="text" match="MIME[Content-Type='text/plain']/BODY">
<div id="textForm">
<textarea id="output" readonly="readonly" rows='30'>
<xsl:value-of select="."/>
</textarea>
</div>
</xsl:template>

<xsl:template name="html"  match="MIME[Content-Type='text/html']/BODY">
<div id="htmlForm">
<xsl:value-of select="." disable-output-escaping="yes"/>
</div>
</xsl:template>
</xsl:stylesheet>

 for the below XML
<BODY>
<Parts>
<MIME>
<Content-Type charset="iso-8859-1">text/plain</Content-Type>
<Content-transfer-encoding>7bit</Content-transfer-encoding>
<BODY>
Here is the text of the message.
</BODY>
</MIME>
<MIME>
<Content-Type charset="iso-8859-1">text/html</Content-Type>
<Content-transfer-encoding>binary</Content-transfer-encoding>
<BODY>
<HTML>
<HEAD></HEAD>
<BODY>
<P>
Here is the html of the message.
</P>
</BODY>
</HTML>
</BODY>
</MIME>
</Parts>
</BODY>


Desired output is to select only the BODY test for the met condition.
Please let me know which is causing the issue here.

Thanks

On Tue, Mar 3, 2009 at 12:14 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>
> I would have two template rules:
>
> <xsl:template match="MIME[Content-Type='text/plain']/BODY">
> ...
> </xsl:template>
>
> and another
>
> <xsl:template match="MIME[Content-Type='text/html']/BODY">
> ...
> </xsl:template>
>
> to match BODY elements based on the Content-Type of their enclosing MIME
> element.
>
> Michael Kay
> http://www.saxonica.com/
>
>> -----Original Message-----
>> From: Senthilukvelaan [mailto:skumaravelan@xxxxxxxxxxxxxx]
>> Sent: 03 March 2009 05:10
>> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> Subject: [xsl] Preceding sibling selction
>>
>> Hi
>> I would like to produce the below expected output, How I do
>> select a BODY, based on the preceding sibling value .
>>
>> If it is "text/plain" It should be shown in text area node.
>> If it is "text/html" and it should be selected and rendered.
>> I need a help in selecting the testing the preceding sibling
>> . I am not sure ,How do I escape a "/".
>>
>> Thanks,
>> SK
>>
>> XML message
>> <BODY>
>> <Parts>
>> <MIME>
>> <Content-Type charset="iso-8859-1">text/plain</Content-Type>
>> <Content-transfer-encoding>7bit</Content-transfer-encoding>
>> <BODY>
>> Here is the text of the message.
>> </BODY>
>> </MIME>
>> <MIME>
>> <Content-Type charset="iso-8859-1">text/html</Content-Type>
>> <Content-transfer-encoding>binary</Content-transfer-encoding>
>> <BODY>
>> <HTML>
>> <HEAD></HEAD>
>> <BODY>
>> <P>
>> Here is the html of the message.
>> </P>
>> </BODY>
>> </HTML>
>> </BODY>
>> </MIME>
>> </Parts>
>> </BODY>
>>
>> Expected output:
>>
>> <html>
>> <div id=htmlForm>
>> <HTML>
>> <HEAD></HEAD>
>> <BODY>
>> <P>
>> Here is the html of the message.
>> </P>
>> </BODY>
>> </HTML>
>> </div>
>> <div id=textForm>
>> <textarea id="output" readonly="readonly"rows='30'> Here is
>> the text of the message.
>> </textarea>
>> </div>
>> <html>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent