xsl-list
[Top] [All Lists]

RE: [xsl] Preceding sibling selction

2009-03-03 18:59:22

Oh dear, you are really struggling with the basics.

You have a recursive structure in which BODY elements are nested inside BODY
elements. This is absolutely the kind of structure that XSLT was designed
for, with its processing model based on recursive descent using matching
template rules. Typically you write a template rule for every element, which
calls apply-templates to process its children using the template rules that
best match the children. I showed you how you could have two template rules
matching different kinds of BODY children based on examining their
properties, or in this case the properties of their parent elements.

The problem is that you aren't understanding the answers you are being given
because you haven't learned the basic concepts of the language. You won't do
that by throwing questions at a forum and hoping for enlightenment in the
answers. Spend some time with a good book (that's always what I do when
trying to learn a new technology). Work through the introductory chapters
carefully and study the examples. Then when you have a specific problem,
come back here with it, and there's a reasonable chance that you will
understand the answer.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Senthilukvelaan [mailto:skumaravelan(_at_)googlemail(_dot_)com] 
Sent: 03 March 2009 22:26
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Preceding sibling selction

Hi ,
Can you please help me ,How do I get two distinct Body text 
values for Different content-Type values?
I could not figure out the missing piece.
Thanks
S

On Tue, Mar 3, 2009 at 12:04 PM, Senthilukvelaan 
<skumaravelan(_at_)googlemail(_dot_)com> wrote:
Hi All,
As Michael suggested, Though I have added two matching 
templates for 
the content-type, My desired output is not showing. I am 
not sure What 
am I missing in here.

My  XML Input looks like this .

<Message>
<Return-path></Return-path>
<Received>
</Received>
<From>testing(_at_)gmail(_dot_)com</From>
<Subject>Testing Mime </Subject>
<MIME-version>1.0</MIME-version>
<Content-type boundary="test">multipart/alternative</Content-type>
<Body>
<Message>
<Content-Disposition>inline</Content-Disposition>
<Content-Type charset="ISO-8859-1">text/plain</Content-Type>

<Content-Transfer-Encoding>quoted-printable</Content-Transfer-Encoding

<Body>
Hello Welcome to MIme Text message.
</Body>
</Message>
<Message>
<Content-Disposition>inline</Content-Disposition>
<Content-Type charset="ISO-8859-1">text/html</Content-Type>

<Content-Transfer-Encoding>quoted-printable</Content-Transfer-Encoding

<Body>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title>Testing MIME</title>
<meta content="text/html; charset=utf-8" 
http-equiv="content-type"/> 
</head> <body> <p> Hello Welcome to MIme HTML message.
</p>
</body>
</html>
</Body>
</Message>
</Body>
</Message>

My XSLT is the below.
<?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="Message[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="Message[Content-Type='text/html']/Body">
<div id="htmlForm">
<xsl:value-of select="." disable-output-escaping="yes"/> </div> 
</xsl:template> </xsl:stylesheet>

I want to show only the Body text value for the said match.
I am not sure ,which node causing the problem to show the 
Body  text value?

Kindly help.



On Tue, Mar 3, 2009 at 12:14 AM, Michael Kay 
<mike(_at_)saxonica(_dot_)com> 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(_at_)googlemail(_dot_)com]
Sent: 03 March 2009 05:10
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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>


--~-----------------------------------------------------------------
- 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>
--~--



--~------------------------------------------------------------------
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>