Re: Apply Templates, when to use which? how do templat
On 8/28/07, John Smith <debrief@xxxxxxxxx> wrote: > The concept of templates is confusing me a bit as I am used to think > of functions like imperative programming languages. So... Just to add to Davids response, a good way to understand templates and the way XSLT works is think about the following stylesheet: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" /> This is a stylesheet with no templates at all - it's an empty element. If you run a transform using that stylesheet with this input: <root example="input"> <node>Hello</node> <node>World</node> </root> ...you get this output: <?xml version="1.0" encoding="UTF-8"?> Hello World This is because of the default template rules. Understand these and soon after you'll "get" templates. Note the indentation, and that the attribute is ignored. Try running the examples, and then add the root matching template: <xsl:template match="/"> abc </xsl:template> Work out why the output is now: <?xml version="1.0" encoding="UTF-8"?> abc Then to answer most of the questions in your original post, try to get the attribute "example" to come out, or make "Hello World" appear all on one line. cheers andrew -- http://andrewjwelch.com
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format