Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2005, 09:45 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT transformation from XML buffer and XSL file

 Hi,
I'm trying to transform a xml buffer using an xsl file in javascript. I'm used "transformToDocument / transformToFragment " methods . Everthing works as long as the xml and xsl are kept as files.

If i use xmlhttp to load the xml file and place it in a buffer and use an xsl file to transform it then, the problem occurs.

The Problem i'm facing is , The xsl file is show as html in the firefox browser. But there is no xml data shown. I'm pasting the code i'm using here.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<script language="javascript">
var xslStylesheet;
var xsltProcessor = new XSLTProcessor();
var myDOM;

var xmlDoc;

  // load the xslt file, example1.xsl
  var myXMLHTTPRequest = new XMLHttpRequest();
  myXMLHTTPRequest.open("GET", "example1.xsl", false);
  myXMLHTTPRequest.send(null);

  xslStylesheet = myXMLHTTPRequest.responseXML;
  xsltProcessor.importStylesheet(xslStylesheet);

  theData = document.getElementById("response_t").value; // the xml data is placed in the textare for testing.

var domParser = new DOMParser();
var xmlDocument = domParser.parseFromString(theData,'application/xml');

 doc = xsltProcessor.transformToDocument(xmlDocument);
 var xmls = new XMLSerializer();

 document.getElementById("example").innerHTML = (xmls.serializeToString(doc));

</script>
</HEAD>

<BODY BGCOLOR="#FFFFFF" onload="test()">
<textarea cols=80 rows="10" id="response_t" style="visibility:hidden;display:none;"></textarea>
<div id="example"></div>
</BODY>
</HTML>

sorry again to repeat. The transformation is good when we are using the xml from a file for transforming. If it is placed in a buffer then the xsl is shown in the browser but with no xml data. This problem is only in the Firefox browser

Thanks in advance.

Kumar S

 
Old September 5th, 2005, 02:11 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

problem solved. there was a problem with xpath xpressions in my xsl file.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
Xml to Xml Transformation using xslt ShaileshShinde XSLT 1 July 20th, 2005 01:20 AM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 08:48 AM
XML to XML transformation using XSLT karjagis XSLT 3 July 30th, 2004 06:13 AM
Server side transformation with- XSL/XML, ASP, IIS kenneth02 Classic ASP XML 3 November 10th, 2003 10:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.