XSLT
Posted: Mon Jun 18, 2007 3:48 pm
I'm missing something about how PHP uses XSLT to convert documents from one type to another, I'm hoping someone can explain.
I understand which each component does (i think).
You essemtially have two documents:
1) An well formed XML document
2) XSL
The latter is a specialized XML document which knows how to take the input (1) and transform it into a other output (ie: HTML, XHTML, etc). Fromwhat I have read in the past it sounds like XSL can be used to convert XML into a PDF file, so I assume that the XSL somehow can tap into the power of PHP, otherwise what PDF API would it use?
If in my XML document I have customized tags which require complicated processing, say for example the tag needs to pull it's data from MYSQL and expand into HTML for final rendering, how is this done? Is this possible inside the context of XSL?
I was thinking you could use a DOM object to traverse a XML document. Whenever I found specially marked tags, I could use them to locate the required objects and connect to MySQL, etc and basically convert the XML tags into the outputted XHTML tags for display.
Sounds like XSL may do this for me, without a DOM.
Can someone tell me if I'm on the right track or am I misunderstanding something? Hows does XSL as a rules based XML file take a XML document and convert it into and XHTML or other form? Is XSL simpler than using the DOM directly as I suggested above?
As I understand it, XSL files simply use trivial conditionals, constructs to say:
transforms into:
In this way XSL provides a simpler transformation than manipulating the DOM directly but is more restricting in that if some tag maps to a field in a DB how does XSL allow you to fetch it and use that data in the context of XSL?
Cheers
I understand which each component does (i think).
You essemtially have two documents:
1) An well formed XML document
2) XSL
The latter is a specialized XML document which knows how to take the input (1) and transform it into a other output (ie: HTML, XHTML, etc). Fromwhat I have read in the past it sounds like XSL can be used to convert XML into a PDF file, so I assume that the XSL somehow can tap into the power of PHP, otherwise what PDF API would it use?
If in my XML document I have customized tags which require complicated processing, say for example the tag needs to pull it's data from MYSQL and expand into HTML for final rendering, how is this done? Is this possible inside the context of XSL?
I was thinking you could use a DOM object to traverse a XML document. Whenever I found specially marked tags, I could use them to locate the required objects and connect to MySQL, etc and basically convert the XML tags into the outputted XHTML tags for display.
Sounds like XSL may do this for me, without a DOM.
Can someone tell me if I'm on the right track or am I misunderstanding something? Hows does XSL as a rules based XML file take a XML document and convert it into and XHTML or other form? Is XSL simpler than using the DOM directly as I suggested above?
As I understand it, XSL files simply use trivial conditionals, constructs to say:
Code: Select all
<author name="Joe">
<age value="29" />
</author>Code: Select all
<div>
<strong>Joe</strong><br />
Age: 29
</div>Cheers