Solved

xsl:Include

Posted on 2002-05-07
9
936 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
 

Author Comment

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

Server.MapPath("xsl/main.xsl"), ....
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unattended XML settings 4 102
jQuery Date picker not working 16 105
Fixed div within Bootstrap carousel item 11 54
Shredding xml into an oracle 11g Database 2 27
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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.
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:
The viewer will learn how to dynamically set the form action using jQuery.

911 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