XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 27th, 2004, 05:21 AM
Rokuk Rokuk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 Rokuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Two Questions About XSL

Hello all!

I've used some XML in webpages before, and haven't had any trouble until recently. I am starting to try to learn some XSL as well, and I understand how it can transform into X/HTML. The trouble I am getting is when instead of transforming the XML into HTML, I just try to modify the XML into a new XML file.

First, I don't see any changes ever occuring, when I open up the XML file (which is linked to the XSL file, similar to how an HTML file is linked to an external CSS file). I assume that when I open up this XML file, it processes the link to the XSL file, and then transforms the output to the browser. However, when I open up this XML file and "View Source" (I am using IE 6), the source of the XML does not change! I'm not sure if the XSL transformations just aren't working, or perhaps I can just not see the transformed XML file this way. If the latter is the case, how CAN you see the transformed XML output?

Second, when you use XSL to transform an XML file to HTML, it is possible to just save the resulting HTML file (by opening it in a browser, and using the browser to save it as an HTML file). I know you can take an XML file and transform it into most anything - say, a PDF file if you wanted to. How can you actually "save" the transformed data into a new file when not dealing strictly with HTML? I would like to save the output of my XML transformation as a new XML file. Is this possible?

I've looked around for answers to these questions, but haven't been able to find anything very helpful as of yet =/ I also haven't seen any information about this in any of the XSL tutorials I have read, they ALWAYS focus solely on doing simple transformations from XML to HTML, and don't seem to want to touch anything else. Perhaps I'm just missing something very simple here?

Thank you very much for any insight you may have!

Reply With Quote
  #2  
Old July 27th, 2004, 06:03 AM
Teflon's Avatar
Teflon Teflon is offline
Teflon The Black
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Woodbridge VA
Posts: 246 Teflon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 28 m 14 sec
Reputation Power: 5
Send a message via AIM to Teflon
To answer the first question, the source is the XML. Second question, what I have done is used php to do my transformations to save a static html page.
Basically you will need a 'program' to transform the xml/xsl for you, not ie, if you are looking to create a static page.
Third question, I think, yes you can use xsl to create xml, remeber that xhtml, IS xml.

PHP Code:
<?php

    $xmlfile 
"joedirt.xml";
    
$xslfile "bighemi.xsl";
    
$result "RESULTS/joedirt.html";
/* Load the two XML sources */
$xml = new DomDocument;
$xml->load($xmlfile);

$xsl = new DomDocument;
$xsl->load($xslfile);

/* Configure the transformer */
$proc = new xsltprocessor;
$proc->registerPhpFunctions();
$proc->importStyleSheet($xsl); // attach the xsl rules

$file_handle fopen($result"w");  //name of the file to write to w is for write
fwrite($file_handle$proc->transformToXML($xml));            //print a crlf
fclose($file_handle);

echo 
"<a href='".$result."'>Click here to go to final html output.</a>";

?>


-Teflon
__________________
Teflon - The Black <desc>Mark This Up</desc>

Reply With Quote
  #3  
Old July 27th, 2004, 07:09 AM
Rokuk Rokuk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 Rokuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
.

Teflon,

Thank you very much for your response! It definately answered my questions. I have done a little bit of work with PHP before, so I will try to make it work following the starting block you have provided. At least now I should be able to *see* the transformed document, as well! = )

One would think there would be a simpler way to view the transformed data... maybe in a perfect world

Thanks again!

Reply With Quote
  #4  
Old July 27th, 2004, 09:42 AM
Rokuk Rokuk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 Rokuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
.

I've thought of another question! = )

Well, as I understand it, to use this method (of using PHP as the program to do the transformations) you need access to the configuration settings and such of a web server. Well, I happen to have access to a webserver that runs PHP, but I don't have any kind of access to get the Sablotron extensions to PHP added to / running on the server.

Is there any way to use another "program" to do this for me? Although PHP would be nice (especially since I've already worked with it a bit), it would be ideal (at least for me) if it was standalone and didn't require any kind of server, or even internet access, so I could do it from a laptop in the middle of a deserted island if I had to Is this possible? I would think it would have to be... although I'm not sure why. =/

Thanks again!

Reply With Quote
  #5  
Old July 27th, 2004, 10:55 AM
Teflon's Avatar
Teflon Teflon is offline
Teflon The Black
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Woodbridge VA
Posts: 246 Teflon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 28 m 14 sec
Reputation Power: 5
Send a message via AIM to Teflon
http://www.xm.co.nz/XML/XSL/msxml3.html
http://xml.apache.org/xalan-c/index.html
Maybe this will help you?

btw. That snippet does not use sablotron, it is php 5 which changed the xsl processor.

Usually all you need to get it to run is uncomment a single line in php.ini.

I thought I saw a javascript solution somewhere that didnt use m$xml. I'll look around some more.

-Teflon

Reply With Quote
  #6  
Old July 28th, 2004, 11:24 AM
Rokuk Rokuk is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 4 Rokuk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
.

Aha!

These are excellent suggestions! I thank you for spending the time to help answer my questions.

Just when you think you know something, you find out you are out of date = ) I have spoken with the administrators of the web server I use, and hopefully then will be adding support for XML translations sometime before next year!

But for now, I will look into the "stand alone processor" and Xalan-C++. It sounds like they may be just the thing/s I've been looking for!

Thank you, Master Teflon

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Two Questions About XSL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT