RE: [xsl] first warning message is printed in output using XSL

Subject: RE: [xsl] first warning message is printed in output using XSL
From: "Sharma, Jaikumar" <jaikumar.sharma@xxxxxxxxx>
Date: Tue, 31 Jul 2007 14:59:03 +0530
Thanks Abel, In fact being new to XSL, I am only seeing the results in
browser, not calling the XSLT procesor from command line. I would have
to try the tip and then see the results.
Thanks again for the help!
Regards.

-----Original Message-----
From: Abel Braaksma (online) [mailto:abel.online@xxxxxxxxx]
Sent: Tuesday, July 31, 2007 2:43 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] first warning message is printed in output using XSL

> Hi All,
>
> I have written the follwing XSL code to parse the XML docuemnt, every
> thing works fine, but last (s.no.3) print the first waring message
> always.

I am under the impression that you are mixing a couple of things up.
XSLT does not print, and a template contains a rule and is only called
when the input complies to that rule.

In this case, when the XSLT processor starts your XML transformation, it
loads the tree and starts with the very first node, the root node (or
document node), and tries to find a match for it. The match is what you
numbered #1.

In that matching template, you instruct the processor that it should
apply other templates than the default templates. In your case, the
target element with the name @main. This may (or may not, depending on
the parts you did not show) trigger the general template with '*'
(any element) matching, your number #2.

In that matching template, you instruct the processor to process all
children of this 'target' element at the child-path 'task/target'
and with the attribute @name set to 'subsystem.build.main'. I have no
clue how your input data looks like, but considering the paths you are
using and the names that you use for elements, it may not exist, in
which case nothing happens here.

Now it gets a bit tricky, because if the above is true, the #2 template
does not 'print' (as you put it) anything, but it does not process
anything either and it does not do a call-template (it does, but it is
never called).

Because your named template is using a matching pattern as well, my
guess is that it is triggered by some other parts of your stylesheet
that you did not show.

As a tip for testing what goes on in apply-templates, use it with
copy-of. This will stop the recursive apply template calls, and shows
you whether a path is correct. The same is true for any other place
where you use a selection by an XPath (like in your xsl:for-each
statement).

If this does not help you, then please send the input data and the
expexted output XML along with a complete example of a working
stylesheet (see also the list guidelines) so we can help you better.


Cheers,
-- Abel Braaksma


PS: you are creating HTML and I suspect you only tested the results in a
browser. If you run it from the commandline, do you still miss the data?
It may be that you HTML is incorrect and that the browser does not
render the way you expect it. In fact, when creating HTML with XSLT it
is best practice to always check the bare output first before testing
the rendered result of a browser.


> -----------------------------------------------
> 1.
> <xsl:template match="/">
>  <html>
>    <body>
>        <xsl:apply-templates
> select="cruisecontrol/build/target[@name='main']" />
>     </body>
>  </html>
>  </xsl:template>
>
> 2.
>   <xsl:template match="*">
>     <xsl:for-each
> select="task/target[@name='subsystem.build.main']">
>           <p style="color: FFFFFF; background-color: 330066; height:
> 2px; font-size: 12pt">
>             <xsl:value-of
> select="task/target/task/message[@priority='warn']" />
>          </p>
>           <xsl:call-template name="javadoc.filter" />
>
>     </xsl:for-each>
>   </xsl:template>
>
> 3.
>   <xsl:template name="javadoc.filter"
> match="task/target[@name='subsystem.build.main']">
>        <xsl:for-each select="task/target/task/target">
>           <p style="font-size: 9pt">
>              <xsl:value-of select="task/message[@priority='warn']"
> />
>           </p>
>        </xsl:for-each>
>   </xsl:template>
> ----------------------------------------------
>
> Does somebody know see, what I am missing here ?
>
> Thanks.
>
>
>
> DISCLAIMER:
> Unless indicated otherwise, the information contained in this message
> is privileged and confidential, and is intended only for the use of
> the addressee(s) named above and others who have been specifically
> authorized to receive it. If you are not the intended recipient, you
> are hereby notified that any dissemination, distribution or copying of

> this message and/or attachments is strictly prohibited. The company
> accepts no liability for any damage caused by any virus transmitted by

> this email. Furthermore, the company does not warrant a proper and
> complete transmission of this information, nor does it accept
> liability for any delays. If you have received this message in error,
> please contact the sender and delete the message. Thank you.



DISCLAIMER:
Unless indicated otherwise, the information contained in this message is
privileged and confidential, and is intended only for the use of the
addressee(s) named above and others who have been specifically authorized to
receive it. If you are not the intended recipient, you are hereby notified
that any dissemination, distribution or copying of this message and/or
attachments is strictly prohibited. The company accepts no liability for any
damage caused by any virus transmitted by this email. Furthermore, the company
does not warrant a proper and complete transmission of this information, nor
does it accept liability for any delays. If you have received this message in
error, please contact the sender and delete the message. Thank you.

Current Thread