Solved

xsl:Include

Posted on 2002-05-07
9
929 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
Comment Utility
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
Comment Utility
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
Comment Utility
Error is a server side ASP Transformation error.
0
 

Author Comment

by:greenrc
Comment Utility
Sorry XSL path S/B

Server.MapPath("xsl/main.xsl"), ....
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 23

Accepted Solution

by:
b1xml2 earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
green, it's been a while. Feedback please.
0
 
LVL 23

Expert Comment

by:b1xml2
Comment Utility
green, second call =)
0
 

Author Comment

by:greenrc
Comment Utility
oXmlDoc.load works ... excellent!

Thanks again Brandon.


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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. 
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now