?
Solved

xsl:Include

Posted on 2002-05-07
9
Medium Priority
?
963 Views
Last Modified: 2013-11-18
I am trying to use xsl:include am am having no luck. Below are the two XSL Files (MAIN.XSL and HEADER.XSL) that i need assistance with.

MAIN.XSL
=================

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="page">
  <xsl:for-each select="element">
    <xsl:if test="type/text()='header'">
     <xsl:call-template name="header" />
    </xsl:if>
  </xsl:for-each>
 </xsl:template>
 <xsl:include href="header.xsl" />
</xsl:stylesheet>

HEADER.XSL
==================

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template name="header">
  <table width="100%" border="0">            
   <tr><td><img src="images/header_left.gif" /></td></tr>
  </table>
 </xsl:template>
</xsl:stylesheet>

=============================
The error message being returned is:

msxml4.dll (0x80004005)
The system cannot locate the object specified. Error occurred during compilation of included or imported stylesheet 'header.xsl'.

==============================

Please note that if i replace the line in MAIN.XSL:

<xsl:include href="header.xsl" />

With:

 <xsl:template name="header">
  <table width="100%" border="0">            
   <tr><td><img src="images/header_left.gif" /></td></tr>
  </table>
</xsl:template>

The transformation works perfectly.

Also note that MAIN.XSL & HEADER.XSL reside in the same directory.

Thanks


0
Comment
Question by:greenrc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 23

Expert Comment

by:b1xml2
ID: 6995686
how do you use the XSLT documents
==================================
Under VB, everything works fine with straight transforms as well as using the XSLTemplate

Under ASP, everything works fine with straight transforms as well as using the XSLTemplate

Under the client, everything works fine with straight transforms as well as using the XSLTemplate.

Tell me where and how are you getting the said error?
0
 

Author Comment

by:greenrc
ID: 6995752
I am transforming the files with the following ASP code:
=============================
Set oXmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set oXslDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set pagexml = FSO.OpenTextFile(Server.MapPath("xml/page.xml"), ForReading, False, TristateTrue)
strXml = pagexml.ReadAll()
pagexml.close
oXmlDoc.loadXML strXml
oXmlDoc.setProperty "SelectionLanguage", "XPath"    

Set strXsl = FSO.OpenTextFile(Server.MapPath("xsl/page.xsl"), ForReading, False, TristateTrue)
oXslDoc.loadXML strXsl.ReadAll()
strXsl.close

PageHTML = oXmlDoc.transformNode(oXslDoc)

XML is as follows:
======================
<xml>
 <page>
  <element>
   <type>header</type>
  </element>
 </page>
</xml>
0
 

Author Comment

by:greenrc
ID: 6995753
Error is a server side ASP Transformation error.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:greenrc
ID: 6995761
Sorry XSL path S/B

Server.MapPath("xsl/main.xsl"), ....
0
 
LVL 23

Accepted Solution

by:
b1xml2 earned 400 total points
ID: 6995778
The ASP Code you used is incorrect.
===========================================
<%
Dim oXmlDoc, oXslDoc
Set oXmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set oXslDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
oXmlDoc.async = False
oXslDoc.async = False
oXmlDoc.load Server.MapPath("xml/page.xml")
oXslDoc.load Server.MapPath("xsl.main.xsl")
oXmlDoc.transformNodeToObject oXslDoc, Response
Set oXmlDoc = Nothing
Set oXslDoc = Nothing
%>

Notes
=====
1. The problem with the linking is that you are using the FileSystemObject to load the file and pass it into a variable and then load it via the loadXML method. Now whenever documents are loaded via the loadXML method, the starting point of the url is taken from the existing asp  page and thus, it is looking for header.xsl in the same directory as the asp page.

2. By using the load method along with the Server.MapPath method, you will be using the url of the XSLT document as the starting point to find the included XSLT document.

Regards,

Brandon Driesen
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6995807
typo with path
====
<%
Dim oXmlDoc, oXslDoc
Set oXmlDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
Set oXslDoc = Server.CreateObject("Msxml2.DOMDocument.4.0")
oXmlDoc.async = False
oXslDoc.async = False
oXmlDoc.load Server.MapPath("xml/page.xml")
oXslDoc.load Server.MapPath("xsl/main.xsl")
oXmlDoc.transformNodeToObject oXslDoc, Response
Set oXmlDoc = Nothing
Set oXslDoc = Nothing
%>
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 6998846
green, it's been a while. Feedback please.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7004300
green, second call =)
0
 

Author Comment

by:greenrc
ID: 7021402
oXmlDoc.load works ... excellent!

Thanks again Brandon.


0

Featured Post

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

801 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