Sorry, I have no better forum to file this under.
Here is my issue. I'm working on a non-profit theater site who uses a third party box office solution for selling tickets in house and on the web. This service publishes showtimes on HTML pages transformed from XML. They will not allow us to style these HTML pages so we will have to make our own XSL transformations, something I know next to nothing about. Since this service they use developed it process at a time before there were such a thing as XML standards and have flat out refused to update their method, all the example XSLT scripts just plain don't work. So, I am approaching the only community I have an 'in' with to help me figure out what I need to do.
It doesn't seem like there is a functional XML import module for Drupal, even though some people have started projects on it. I am not sure we want to create nodes for each showtime either. In the end, I need to create seven HTML files to SSI into drupal nodes for each day of the week. I don't know all of the date formatting and sorting vocabulary but I'll cross that once I get there.
I found this code that works just great in a practice environment with dummy files:
// Allocate a new XSLT processor
$xh = xslt_create();
// Process the document
if (xslt_process($xh, 'aa_showtimes.xml', 'aa_format.xsl' , 'result.html')) {
print "SUCCESS, sample.xml was transformed by sample.xsl into result.xml";
print ", result.xml has the following contents\n<br>\n";
print "\n"; readfile('result.html'); print "
\n";
}
else {
print "Sorry, sample.xml could not be transformed by sample.xsl into";
print " result.xml the reason is that " . xslt_error($xh) . " and the ";
print "error code is " . xslt_errno($xh);
}
xslt_free($xh);
It's all fine and dandy but the XML data is a web link, not a file, and I'm not even sure if its well-formed. In my back asswards understanding, I tried to swap the aa_showtimes.xml file with the link to their XML data:
http://www.readyticket.net/webticket/webticket2.asp?WCI=getxmlshowtimes&...
Needless to say it seems to break, either because of my poor understanding or because of their bad XML. The error message I get here is, "Warning: Sablotron error on line 1: XML parser error 4: not well-formed in /home/schottfe/public_html/aa_process.php on line 7".
I found a comment on another board that suggests how to override the poorly formed data:
http://us3.php.net/manual/en/ref.xsl.php
But I can't make that example work either.
Do any of you PHP speaking geniuses have a tip or two for me? I would also love to find another online community that more specializes in PHP specific coding, I know most of the commentary on drupal.org is related specifically to drupal.
Comments
Just my opinion
XSL on random non semantic HTML is doomed to failure, unless you can convert it to valid XHTML.
You might want to look into HTMLTidy to hopefully tidy up the HTML and do the conversion for you.
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Example Knowledge Base built using Drupal
Just a reply so I can find it tomorrow
Subject says it all. By the way though, try pointing firefox at the link, you can view it then.
I’m no XSLT guru or XML
I’m no XSLT guru or XML pro so this could all be rubbish
I had a similar problem a month or so back and I ended up going with using a curl library to retrieve xml data from an external source
and calling the function with
this may not help you as you are also trying to use SSI but it might give you some ideas
what does the xml file look like – are the tags the fields of interest or is the data in attribute fields inside the tags
You will have to excuse my
You will have to excuse my ignorance about PHP, but how do I put these two pieces of code together with the sample XSLT script I worked out above? Would it look like this? I'm just taking a stab in the dark based on my scripting knowledge from FileMaker!
Test available
If you want to see the error on this one:
http://www.coolidge.org/drupal/aa_process2.php
It says:
Warning: Sablotron error on line 1: XML parser error 4: not well-formed (invalid token) in /home/coolidge/drupal/aa_process3.php on line 22
Sorry, sample.xml could not be transformed by sample.xsl into result.xml the reason is that XML parser error 4: not well-formed (invalid token) and the error code is 2
Sorry just saw the rest of
Sorry just saw the rest of this try - create a page and put every thing below in - enable php
Bang
This is the answer to all my questions. Thanks so much for helping me sor this out, I couldn't have done it on my own. I placed this code into a node, bookended with the right HTML, and it displays the data just like I needed it.
Now all I need is a good resource for writing XSL templates, especially dealing with date functions.
Thanks again!
Updated XML link
I've tried using this link to the XML data too. Even though I get the same errors I believe it is more direct:
http://www.readyticket.net/webticket/htmlshowtimes/130/showtimes.xml
Sorry I havent looked at
Sorry I havent looked at your code but what error are you getting
I tried
And i get a display of your data
No good
When I try yoru code I get this error. Use http://www.coolidge.org/drupal/aa_process4.php
"Parse error: syntax error, unexpected T_STRING in /home/coolidge/drupal/aa_process4.php on line 4"
Maybe there is something not config right on our server?
http://www.coolidge.org/drupal/aa_phpinfo.php
Strange that should work
Strange that should work T_STRING might be a snytax error - I would guess that if the xml object wasnt install then it would reply with function not found
try removing all white space in line 4 (where the xml file is being called)
Whitespace may have been an
Whitespace may have been an issue, I deleted everything I could and now I have a different error. Bummer. I just don't understand enough PHP to do this myself.
http://www.coolidge.org/drupal/aa_process4.php
Yeh that error looks familar
Yeh that error looks familar and i think thats how i ended up using the httpRequest though it does seem strange that i can get it working on my system
if you google the error you get somthing like
http://www.codecomments.com/archive227-2005-7-529092.html
but I've got no idea whats going on in changing the settings (risky)
check your php info down near the botton it should tell you what xml support the server has
Your system
When you say you have it working on your system does that mean when you run the script off the link in this thread it works, or does it mean you have a similar script running on another server? If it is the latter, can you link it for me?
non-admin can't view it!
msomers, the code you posted did wonders for me. But this freaky thing happens and I can't figure it out. When I create a node as an admin, making sure that there are all the correct privileges and stuff, and using the code below - ONLY the admin account can see the output. Other anonymous and registered users can't see anything but the headline, even the HTML above and below the script are invisible. Log back into admin, and there it is? What am i missing?
To see it (or rather, not see it) go to: http://www.coolidge.org/drupal/showtimes
When you say you create a
When you say you create a node are you meaning creating a single page
Try taking the code out and doing a hello world
if that works it a problem with the code
make sure that php code is switched on instead of using filtered or full html
hope that makes sense
I realized that this problem
I realized that this problem is actually site wide, not just with this PHP page. Logged in as admin I see pages as they are supposed to appear. If I am logged out, or logged in as an average user, then I see only the title of each node, but no body. The theme and blocks all appear as normal either way.
Solution
This is the solution we found, this was posted in the middle of this thread, just wanted to stamp it at the bottom for anyone looking for the same answer. Thanks to all for the help.
Hello.
Hello.
Let me explain why I am posting here for help...
I am making a World of Warcraft guild website and one of the things the guild needs is an always up to date guild roster. I want to use the information shown here http://www.wowarmory.com/guild-info.xml?r=Boulderfist&n=Forsaken+Deity&p=1 which when you view the source you can see it is XML, and show a similar listing customized to my liking on my guilds site.
Now I entered the code above into a page, and set it to accept PHP as input and whatnot...
I changed the URL in the line of code below to the link that I think I should be using to pull XML... the code looks like what is below.
After pressing submit, I get the error below... The page won't even create...
Fatal error: Call to undefined function xslt_create() in /home/forsake2/public_html/test/drupal-5.3/includes/common.inc(1347) : eval()'d code on line 17
Can anyone help me sort out how to do this?
Are you using PHP 4.* or 5.*
Are you using PHP 4.* or 5.*? And have you checked that your PHP has the XSLT extension builtin?
I'm using hostmonster for my
I'm using hostmonster for my hosting which uses PHP version 5.1.6. I am going to have to contact them to verify about the XSLT extension as nothing is coming up when I do a search on their helpdesk page. :(
Now in the event it doesn't have it... is there another way to get the XML info from the other site?
Hi. I just added XSLT to my
Hi.
I just added XSLT to my PHP and from what tech support has hold me, it should activate the extension...
Hi. XSLT is installed on
Hi.
XSLT is installed on their server.
Now... it lets me hit
Now... it lets me hit submit, and then when I try to view the new page I created it gives me the error below
And the code entered into the create content > page is:
PHP 5 does not support the function
PHP 5 uses a different lextenstion than PHP 4 for this. PHP 5 uses the XSL extension.
I found this on the
I found this on the w3schools site... I'm wondering if this is going in the right direction. According to w3schools... "This example is a cross-browser example that loads an existing XML document ("note.xml") into the XML parser." (http://www.w3schools.com/xml/xml_parser.asp)
Would the example below be the right idea?... I have no idea. I'm kinda hoping you'd have an idea...
FYI... my msn is ms [dot] kristina [dot] hall [at] gmail [dot] com . I would really appreciate speaking with you directly about this. Maybe we could work together and come up with a module for future WOW guilds...
I don't think you're heading in the right direction
You've gone from trying to use XSLT to transform XML using PHP for use inside Drupal (which is what I assume you want to actually do), to just parsing some XML in the browser using Javascript (which is what I assume you don't want to do).
Try building on the examples here:
http://us.php.net/manual/en/function.xsl-xsltprocessor-construct.php
You will need XSL enabled in your PHP though - try this code to test that:
http://us.php.net/manual/en/function.xsl-xsltprocessor-has-exslt-support...
--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal
I'm doing my best to hack
I'm doing my best to hack this on the very little knowledge I have. :( I hate not knowing enough but I truly do wish to succeed in doing what my guild wants and needs. Hopefully I'm a few steps closer this time....
FYI my MSN is ms [dot] kristina [dot] hall [at] gmail [dot] com ... I would really appreciate speaking with someone knowledgable directly.
ON PAGE IN DRUPAL
EXAMPLE XML from http://www.wowarmory.com/guild-info.xml?r=Boulderfist&n=Forsaken+Deity&p=1 as I cannot view the XML directly from http://www.wowarmory.com/guild-info.xml
XSL STYLESHEET
I've never used XSL in PHP before
so I'm just guessing, but there were a few things that occurred to me:
First of all - what did your code do? what errors did you get? did that check for the XSL extension work?
Looking through your code, I'll use PHP comments for questions/pointers:
--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal
Thank you so much for your
Thank you so much for your time and comments. I didn't run the code, in fact it was more hypothetical... as, I'm not very familiar with XML, XSL, XSLT, etc... More of a designer trying to get something to do what I want it to do... if you know what I mean.
I did my best to heed your advice and wrote up some code to enter into a drupal node, as well as uploaded the xsl file I created to my server.
This is the code in the node:
This is the XSL file:
Below are the errors I am getting when attempting to view the node:
Nearly out of ideas
As I said, my experience of XSL is pretty rudimentary and I've never used it with PHP before - but...
As far as I can tell your PHP code looks correct. I think the problems are with the XML bits.
One thing I would try is to save that XML data locally so you can edit it (at least until you can get it working).
Some rough ideas based on trying to decipher those error messages:
It looks like your XSL file doesn't have the XML declaration bit at the top eg:
<?xml version="1.0" encoding="UTF-8"?>
And it looks like PHP doesn't like the
<?xml-stylesheet type="text/xsl" href="/layout/guild-info.xsl"?>
processing instruction (PI) in the XML data. That PI tells the browser which XSL transform to use on the data to render that flash looking HTML page from the raw XML - but you don't need that PI because you aren't using the browser and you have your own transform being used on your server. When I do "view source" on that page in Firefox I see the raw XML instead of the transformed HTML.Also you might want to edit the XML data so that the
<page ...>
element starts on its own line below the PIs.My untrained eyes seem to think your XSL is roughly correct, but I can't confirm that. Note: you might want to remove the presentational bits from the HTML output though - ie the bgcolor and align attributes.
After that though, I'm all out of ideas.
--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal
subscribing. Getting XML
subscribing. Getting XML feeds to nodes is what I am interested in.
Greetings,
Martijn
Solution
I played around with this and actually found out the issue was mainly in the xslt file.
Here is the php code I placed in my node:
The wowarmory.xslt file referenced is:
Ooops
I forgot I left something in there that was incorrect. The PHP code should be as follows:
This involved removing the $filebase portion of the code.
James
the only change I can see
the only change I can see here is the encoding "UTF-8" why ??
Changes
The filebase was also removed.
Timing out
I tried using this today and now my connection times out and I don't get any XML from WoWArmory.com. I can take the URL in there and go straight to the site, so I am wondering if they blocked it. Has anyone else had any issues with this?
James