XSLT conditional include of external file

后端 未结 8 2074
情书的邮戳
情书的邮戳 2020-12-20 20:14

I want to perform a conditional include in XSLT, but xsl:include is a top level element. You can only use xsl:if or xsl:choose inside of a template. Is there any kind of hac

8条回答
  •  春和景丽
    2020-12-20 20:39

    As I understand things, 'include' happens when the xml parser is parsing and compiling the style sheet. This means that no logic or expression evaluation can happen before the include gets processed and therefore there's no way to make it conditional as such. You need to make the conditional behavior happen outside of the style sheet.

    Have a look at this http://www.dpawson.co.uk/xsl/sect2/N4760.html#d6065e100

    In particular does this comment by Mike Kay help:

    This has been raised a number of times. On a previous thread we came to the conclusion that the user was trying to write a general-purpose stylesheet G and then specialize it by conditionally including a special-purpose stylesheet A or B. The way to meet this requirement is to have A and B include G, not the other way around, and then you conditionally select A or B as the principal stylesheet when starting the transformation.

提交回复
热议问题