xsl-list
[Top] [All Lists]

Re: [xsl] XSLT Concepts

2010-10-01 08:30:04
chirag matkar wrote:

1)When we apply a Template<xsl:apply-templates/> the whole text within
the tags in input file data gets applied and new  element  are
processed as we declare them.

<xsl:apply-templates/> is short for <xsl:apply-templates select="node()"/> so it selects all child nodes of the current node for further processing.

So when we use <xsl:value of select=""/> ,additional data is
processed.This results into extra junk data as i have noticed.How to
avoid such circumstances.?

I am not sure what you are talking about. Can you post an example of the input, the XSLT, the output you get and the output you want and then explain what kind of "junk" you see in the output you get? It might be that you just want <xsl:apply-templates select="*"/> to process only element child nodes and not text nodes between element child nodes, it might be that using xsl:strip-space in your stylesheet can avoid the "junk" but I am not sure that is the problem.

2)Also Suppose we tag the input data with new elements,the tags appear
in the sequence of initial text in the data.How can we sequentially
keep changing order of the data as we wish and apply templates
accordingly.
Example -  we need to tag article title which appears at end in the
input file but we wish to have it tagged first in the output file.ie
change order of tags according to our requirements.

Well with XSLT 2.0 you can do
  <xsl:apply-templates select="foo, bar, baz"/>
to process the "foo", "bar" and "baz" child elements in that order and not in the order they appear in the input document.
With XSLT 1.0 you would need to write three apply-templates e.g.
  <xsl:apply-templates select="foo"/>
  <xsl:apply-templates select="bar"/>
  <xsl:apply-templates select="baz"/>

3)Can we template match a tag more than one time and process nodes
within it sequentially?

I am not sure I understand what you want to achieve. Modes can help processing nodes several times e.g.
  <xsl:apply-templates select="foo"/>
  <xsl:apply-templates select="foo" mode="m1"/>
and
  <xsl:template match="foo">...</xsl:template>
  <xsl:template match="foo" mode="m1">...</xsl:template>
would allow you to process "foo" elements twice.


--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

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