xsl-list
[Top] [All Lists]

Re: [xsl] <xsl:apply-imports/> with select attribute

2013-12-19 08:22:18
On Thu, December 19, 2013 12:35 pm, Christian Mahnke wrote:
What would you want this construct to actually do?

My use case is as follows: I?ve got a master template, in which the
template @match="/" contains a <xsl:for-each/> over a collection(). Inside
the loop I would like to call templates from imported stylesheets, that
are designed to handle single documents. Additionally they haven?t be
designed to run together with other templates, so they contain no @mode
attribute on their template @match="/".

So it sounds like you can't or don't want to modify those stylesheets.

This way the calls to <xsl:apply-templates select=".?/> (where . is a
document node from the collection) doesn?t match the root template of the
imported stylesheet, but the root template of the master stylesheet, which
causes a unwanted loop.

I?m just looking for a way to be able to give the imported stylesheets a
higher priority when I?m looping to a collection of files.

Are you able to start from an initial named template rather than matching
on '/' in your initial stylesheet?  If so, and if there's no template for
'/', then you can just use xsl:apply-templates.

If you were able to match on the document element instead of the document
node, you could potentially do the same.

If your source XML uses a different document element name from the
documents in the collection, then you could use a more specific match
pattern, e.g., '/name-of-source-document-element' and use
xsl:apply-templates to process the documents in the collection.

From your template for '/', instead of using xsl:for-each, you could apply
templates on the document nodes in the collection but use a mode, and from
the template for '/' in that mode, use xsl:apply-imports.

Regards,


Tony Graham                                   tgraham(_at_)mentea(_dot_)net
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--