apply-templates and don't come back...? (Full Version)

All Forums >> [Ask XML questions here] >> XSLTalk (Programming)



Message


claes -> apply-templates and don't come back...? (15 September 2008)

Hi,
I am pretty new to xslt and have a basic question.
I have a set of template rules that styles a pdf document from raw xml data. In my xml there is an element <overview> that is always at the very end of the doc before the closing </root>. In some cases I want to branch on a variable after writing some of the <head> element data at the top of the doc (with <xsl:template match="root/head/title">), and if the var has a value "x" I want to apply-templates select="../../overview" /> and write out the content of <overview> and then stop!

In my output I get the <head> content, then the <overview> content (just like I want), but... then it "jumps back" and continues with all other elements between <head> and <overview>.
Why is that? I thought after the "apply-templates select=..." it would jump to overview but not continue with the rest of the doc, since there is no other apply-templates after the jump to <overview>...

Maybe I am being unclear, any help and suggestion are welcome! I am happy to try and clarify if needed.

Thanks!!
/Claes




nickat -> RE: apply-templates and don't come back...? (16 September 2008)

quote:

ORIGINAL: claes
then it "jumps back" and continues with all other elements between <head> and <overview>.
Why is that? I thought after the "apply-templates select=..." it would jump to overview but not continue with the rest of the doc, since there is no other apply-templates after the jump to <overview>...


It always "jumps back" because the input tree is traversed recursively and all matching templates are applied to every node.

You can use modes to choose different templates based on some condition.

It's hard to give some concrete advice, since I don't have the whole picture. Some essential parts of your stylescheet, an example of an input and expected output could help.




claes -> RE: apply-templates and don't come back...? (17 September 2008)

Thanks,
I guess I didn't understood the recursive traverse, but now I do [:)]
I read about modes and that will do the trick for me!

Thanks again!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.109375