Jump to content

101 apply-templates and template location in file


snowsalt

Recommended Posts

This really is a 101.I need to know if I've got this.When the parser begins processing the xslt it doesn't matter where in the file the templates are located. It looks for a match; period.When the parser hits apply-templates it has rules about which template to apply. As above, it hasn't anything to do with where the templates are located in the xslt file. In fact, it's like starting all over again except in a different state (current node, vars? ....)If in processing the parser passes a node or element (it selects something beyond or inside) that had a matching template, and that template was never applied, too bad. It doesn't ever get applied.Is that right?Now, off to get a book.

Link to comment
Share on other sites

With XML and XSLT the term "parser" is used for "the XML parser", the XSLT stylesheet is executed by the "XSLT processor", usually after an XML parser has been used to parse the XML input document into an in-memory tree model on which the XSLT processor then operates. As for applying templates, processing starts with a matching template for the document node, there are however built-in templates http://www.w3.org/TR/xslt#built-in-rule. so even if you don't have a template for the document node in your stylesheet something is going to happen. As for location of templates not being relevant, it depends on whether there are several matching templates with the same priority, if there are then either the XSLT processor can signal an error or it has to choose the template occurring last in the stylesheet.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...