[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: <xsl:apply-imports> and rules with higher priority
For most applications, I think <xsl:next-match> is more likely to do what you want than <xsl:apply-imports>. It's certainly easier to understand. xsl:next-match simply defines an ordering of all the template rules for a mode, ordered first by precedence, then by priority, then by document order; it finds the current template in that list, and calls the next one down the list that matches the current node. xsl:apply-imports is a bit more complicated; it only considers rules in an "imported stylesheet layer", where a layer means a stylesheet that you import, plus all modules that include or are included by that module. The big advantage of next-match is that it allows you to invoke lower-priority templates in the same module. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Johannes Neubauer [mailto:johannes.neubauer@xxxxxxxxxxxxxxxxx] > Sent: 04 June 2008 16:41 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: <xsl:apply-imports> and rules with higher > priority; And more! > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi, > > The XSLT 2.0 Programmers Reference says, that > <xsl:apply-imports> calls the next template rule with lower > stylesheet level (is that the same like stylesheet layer?) > matching the same node as the current template. > Furthermore it does NOT call template rules with lower > priority in imported stylesheets. What is about rules with > higher priority in an imported stylesheet with lower import > precedence? > > In addition: Does <apply-imports> relate to (one of) all > stylesheets with lower import precedence or only to the ones > imported by the current ~ stylesheet (or stylesheet layer)? I > know this works: > > A import C > A include B > => (import precedences: A = 2, B = 2, C = 1) B and A are on > the same layer, so <apply-imports> in A or B can involve C. > > But does this work to?: > > A import C > A import B > => (import precedences: A = 3, B = 2, C = 1) B has higher > import precedence than C. Does that mean <apply-imports> in B > can call a template rule in C? > > Last but not least: I'd like to call <apply-imports> and if > there was another rule with higher priority, but a lower > import precedence I'd like to return the result of it, else > it should return the result of this template. But I don't > know how to access the information if there was another matching rule. > > I like to change the rule that import precedence decides > which rule matches before rule priority like this: > > Stylesheet B.xsl & C.xsl: > <xsl:template match="test" priority="1 (: for B, 2 for C :)"> > <xsl:choose> > <xsl:when test="there is another template rule > for apply-imports with higher priority"> > <xsl:apply-imports/> > </xsl:when> > <xsl:otherwise> > <!-- sequence constructor for B or C > respectively --> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > > Stylesheet A.xsl: > <xsl:import href="C.xsl"/> > <xsl:import href="B.xsl"/> > > <xsl:template match="/" > > <apply-templates/> > </xsl:template> > > wfg, > Jonny. > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFIRreKGaEJacf6i/cRAk3GAJwMzrLBjQyByBqd3wVCL6qGeG3dzgCeMEQK > 7NRuOtmAJH0WH2UKxv43Zkc= > =mb58 > -----END PGP SIGNATURE-----
|
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
|