Solved

xsl:Include

Posted on 2002-05-07
9
943 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

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

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

Accepted Solution

by:
b1xml2 earned 100 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery tracking event. 3 79
Problem to ToolkitScriptManager 2 67
Excel file not created as expected 7 79
Fulfillment API php code sample 1 58
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa‚Ķ
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

829 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