Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

import an XSLT file into another XSLT based upon a condition

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi,

From the experiemtns that I have done I am pretty sure that this isn;'t possible but I thought I'd ask anyway.

I have an XSLT that based upon a parameter passed in i want to conditionally include another xslt.

so my code would look something like:

Code:
<xsl:choose>
 <xsl:when test="$a = 1">
    <xsl:import href="1.xsl" />
 </xsl:when>
 <xsl:when test="$a = 2">
  <xsl:import href="2.xsl" />
 </xsl:when>
</xsl:choose>
<!-- rest of the xsl document here -->

when i run this i get an error saying xsl:import isn't allowed in this position and when i move it to the top of the xsl file i then can't use xsl:choose.

Is there another way to achieve this?

Tony
 
xsl:import must be a top-level element, which means it must be immediately subordinate to the xsl:stylesheet element.

Perhaps you could describe what you are trying to accomplish with this 'conditional import/include' so that we might make a recommendation of a different way.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top