Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Preceding sibling selction

From: "Michael Kay" <mike@------------>
To:
Date: 3/3/2009 11:59:00 PM
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@xxxxxxxxxxxxxx]
> Sent: 03 March 2009 22:26
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxxxx> 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@xxxxxxxxx</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@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