Solved

xsl:include

Posted on 2000-04-10
7
695 Views
Last Modified: 2013-11-18
Could someone please help me figure out where i'm going wrong. I have the following files:

animal.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="animal.xsl"?>
<animal>
      <horse>
            <name>Mr Ed</name>
            <legs>4</legs>
      </horse>
      <monkey>
            <name>Curious George</name>
            <legs>2</legs>
      </monkey>
</animal>

animal.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
      <xsl:template match="/">
            <xsl:apply-templates/>
      </xsl:template>      
      <xsl:template match="animal">
            <xsl:for-each select="horse | monkey">
                  <xsl:apply-templates/>
            </xsl:for-each>
      </xsl:template>
      <xsl:template match="name">
                  Name:<xsl:value-of/>
            <BR/>
      </xsl:template>
      <xsl:template match="legs">
                  Legs:<xsl:value-of/>
            <P/>
      </xsl:template>
</xsl:stylesheet>

Animal.xml will display as expected in IE5.0 with headings 'Name' and 'Legs' and corresponding data.
I want to add an xsl:include directive to my xsl doc (I'm putting it immediately after the xsl:stylesheet element). But I get the error:
Keyword xsl:include may not be used here.
If I change the xsl namespace to "http://www.w3.org/1999/XSL/transform" then I don't get the error, but my output is now just the titles 'Name' and 'Legs' and not the data .

Thank you.
0
Comment
Question by:fwickes
  • 3
  • 3
7 Comments
 
LVL 27

Expert Comment

by:BigRat
ID: 2709498
The second namespace link (if it is at all used!) is ambiguous. The xsl:include MUST go in after the xsl:stylesheet element (so the spec). Are you sure that you got the xsl:include directive correct? Furthermore the include expects a complete stylesheet which it will parse and extract the children from the xsl:stylesheet element.
0
 

Author Comment

by:fwickes
ID: 2709541
is this right?


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:include href="animal2.xsl"/>
.....
rest of xsl as above
.....


...where animal2.xsl is a valid well-formed xsl
0
 
LVL 27

Expert Comment

by:BigRat
ID: 2709792
Providing the path to animal2.xsl is correct and your last comment also holds then - yes.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:fwickes
ID: 2709854
.so can you think a possible reason I get the error
"Keyword xsl:include may not be used here" ?? Could it just be that my parser(XSpy, IE5.0) doesn't support the include directive? If this is the case do you know of one that does?
0
 
LVL 27

Expert Comment

by:BigRat
ID: 2713685
I admit that the error message is strange "...not expected here"!? Since the spec says that it MUST be there and nowhere else. I don't know if it does support include (I'll try and find out), but you could try one last thing - try putting it BEFORE the stylesheet tag (just to see).
0
 
LVL 1

Accepted Solution

by:
sistudio041900 earned 50 total points
ID: 2730471
Look at: http://msdn.microsoft.com/xml/xslguide/conformance.asp

* "Import/Include (section 2.8). Workaround: Include can be simulated with external entities."

I checked all the possibile things with MSXML3 and there is no way! import and include just dont work in MSXML3 march release. So you need to use other means or other tools. Sorry for not giving the direct solution but this is answer to the question/problem.

you are not doing anything wrong. I copied the W3C example code and checked. MSXML3 just done have xsl:include

workaround: I wrote an commandline xsl-converter (10 lines of Delphi code, uses msxml3) that converter can be modifiled to support include file, ie the commandline tool would read al the xsl, check for include, merge and run MSXML3





0
 

Author Comment

by:fwickes
ID: 2732315
Thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will learn how to count occurrences of each item in an array.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now