Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 3rd, 2005, 09:45 AM
Registered User
 
Join Date: Sep 2005
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old September 5th, 2005, 02:11 AM
Registered User
 
Join Date: Sep 2005
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:37 AM.


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