Re: [xsl] XSLT Concepts

Subject: Re: [xsl] XSLT Concepts
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 01 Oct 2010 14:29:31 +0100
On 01/10/2010 13:50, chirag matkar wrote:
Hello Friends,
I am an Amateur Developer in Xsl transformations.
I work on Research Article XML conversions.
I just want to be clear on some Concepts of XSLT.

the first concept that you need to be clear on is that XSLt never processors tags (neither on input nor output) the tags that (may) appear in an impyt file are processed by an XML parser which produces a tree of nodes (actually it may produce a stream of events made into a tree later but that's an implementation detail)



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.

No (conceptually, and usually in practice) the entire input document has been parsed into an in memory node tree before the transformation starts.



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.?

xsl:value-of produces a text node with the string value of the nodes that are selected. if you consider that to be junk then presumably you are not selecting the nodes that you want to select, but since you give no information it is impossible to give any advice.



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.

lots of ways, please read the posting guidelines for this list, which suggests ways to make it easier for people to help. Specifically providing small runnable examples.


One way, if you have added <foo>....</foo> at the end of your output file, then

in the template for the parent of foo, use

<xsl:apply-templates select="* except foo"/>

so foo is not processed at that point.

and in the template where you want foo to appear at the start of your document do

<xsl:apply-templates select="//foo"/>

as noted in the reply to your first question, the entire input document is made into a tree in advance so every template has read access to the entire document.





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

You can never match tags at all, the XSLT processor has no information about the tagging used in the document, it can not tell if you used <p/> (one tag) or <p></p> (two tags). You can apply templates to element nodes as often as you want, either with the same mode (if you want the same processing each time) or different modes 9if you want different processing.


Thanking You.




David



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread