Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2005, 04:19 AM
Authorized User
 
Join Date: Apr 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl:import or xsl:include

Hi All,

I have to import xyz.xsl in my main.xsl.

xyz.xsl contains:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<test>
<xsl:variable name="nxe_1" select="//para/note"/>
<test>
</xsl:stylesheet>

And main.xsl contains:
<?xml version="1.0" encoding="UTF-8"?>
<sample>
  <para>Sample para.<note>This Note is not to be translated</note>Sample para.</para>
</sample>

How will i use import and include for transformation to get

Output.xml:
<sample>
  <para>Sample para.<test><note>This Note is not to be translated</note></test>Sample para.</para>
</sample>





 
Old August 17th, 2005, 04:22 AM
Authorized User
 
Join Date: Apr 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Corrections:

It's main.xml not main.xsl


 
Old August 17th, 2005, 04:49 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Neither of your two .xsl files is a valid stylesheet.

I don't think xsl:include or xsl:import is likely to be part of the solution to your problem. It would be better to describe what you are trying to do.

I'd suggest the following:

<xsl:template match="*">
  <xsl:copy>
  <xsl:copy-of select="@*"/>
  <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<xsl:template match="para/note">
  <test>
    <xsl:copy-of select="."/>
  </test>
</xsl:template>

This follows a standard design pattern for transformations of the form "copy everything except XYZ": you write one template rule for "everything" that does a (recursive) copy, and another for XYZ that does something different.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic xsl:include? rushman XSLT 7 October 16th, 2012 05:26 AM
Performance for <xsl:import> and <xsl:include> vikkiefd XSLT 2 April 16th, 2008 08:06 AM
xsl import/include mapping sammyj727 XSLT 3 July 19th, 2007 04:15 PM
xsl:include / import and tomcat amitda XSLT 2 April 17th, 2007 10:37 AM
how to include jsp page in xsl vijayanmsc XSLT 2 August 23rd, 2006 05:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.