Hello,
I have a program that i can automate to produce an xml report each morning.
Staff would like the information contained in the page viewable as a webpage.
To make any sense of the XML i have followed a guide and created an XSL page. I undertsand that if the XML page contains a reference to the XSL page then the page can be rendered correctly.
The formatting will never change so the XSL can stay static.
I have done all this and it works great i have a page displaying the XML nicely on a webpage. But how do i get each new, daily generated XML page to know that it has to reference the XSL page? I would like this to be autmated if possible. Is there a way of injecting the reference?
Am i going about this the wrong way round?
TIA

No, you're going about it the right way. What you haven't said is how the XML gets generated...
The program is a behaviour recording system. It can generate a file, such as the shortened one i have attached. I can create an xsl file that can produce a table and separate the headings into columns, but i am not sure how to make all newly produced files,- link to the xsl file.
Last edited by steele_uk; 26th January 2009 at 12:46 PM.

I'd obfuscate that file a bit more thoroughly.
You either need to have your stylesheet link embedded by whatever generates the XML, or do it yourself later on, either by hand or automated.
All the names have been chnaged to protect the guilty!
I am trying to find how to automate the referencing/ embedding of the xsl file.
Any ideas?
Assuming you're on a linux system, try a cron job running something like
... or something on the generated file.Code:sed -e 's/^<(.*?)>/<\1><?xml-stylesheet type="text/xsl" href="mystyle.xsl"?>/' inputFileName > outputFileName
That should use sed to parse the file named inputFileName, find a match to the regex, and replace it with something else, then store that processed file in outputFileName.
The quoted bit breaks down as:
s - Search and replace
/^<(.*?)> - find me the start of the file (^), then a <, then stuff until a >
/<\1><?xml.....?> - replace it with < then the stuff you found before, then >, then <?xml...?> (your stylesheet reference).
I've not tested this and verified the exact syntax, but I'd expect something in that direction to do the job.
... of course if you're on a Windoze server you'll not have the same tools, so I can't help you there. Good luck.
Hello
:-Dave
There are currently 1 users browsing this thread. (0 members and 1 guests)