Fun with XSLT
am 22.10.2009 17:01:52 von Matthew Croud
--Apple-Mail-33-891122241
Content-Type: text/plain;
charset=US-ASCII;
format=flowed;
delsp=yes
Content-Transfer-Encoding: 7bit
Hi Guys,
Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,
just finishing the meaty parts of my XSLT for dummies book too.
I have a question which asks "is it possible?".
Using XSLT I can collect specific parts of my XML using something sexy
like . Lets say however, that I need to
use XSLT, but I would want the user to select which element they
request. In other words, they are given a form with options and that
form can manipulate the .XSL file.
Now I know it could be done in a lengthly manner by just opening the
XSL file and manipulating it like fopen or something like that, but is
there a way to somehow embed the contents of the xml into the php code
(like using <<< EOF for html), and being able to substitute the
template match string for a variable ?
Any ideas ?
Thanks Gamesmaster,
Matt
--Apple-Mail-33-891122241--
RE: Fun with XSLT
am 22.10.2009 17:25:35 von Andrea Giammarchi
--_ba101ff2-f10a-4bce-bec1-cbf5cfb98eff_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
> is =20
> there a way to somehow embed the contents of the xml into the php code =20
> (like using <<< EOF for html)=2C and being able to substitute the =20
> template match string for a variable ?
>=20
> Any ideas ?
XSLT should be used via modules=2C as is with match and templates indeed.
The only idea is to save single modules in order to be able to create run-t=
ime the proper transformer for the specific case.
Then you can save these grouped modules into other modules ... I know it's =
more easy to say than do it.
Regards
=20
____________________________________________________________ _____
Windows Live: Friends get your Flickr=2C Yelp=2C and Digg updates when they=
e-mail you.
http://www.microsoft.com/middleeast/windows/windowslive/see- it-in-action/so=
cial-network-basics.aspx?ocid=3DPID23461::T:WLMTAGL:ON:WL:en -xm:SI_SB_3:092=
010=
--_ba101ff2-f10a-4bce-bec1-cbf5cfb98eff_--
Re: Fun with XSLT
am 22.10.2009 17:39:33 von Peter Ford
Matthew Croud wrote:
> Hi Guys,
>
> Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,
> just finishing the meaty parts of my XSLT for dummies book too.
>
> I have a question which asks "is it possible?".
>
> Using XSLT I can collect specific parts of my XML using something sexy
> like . Lets say however, that I need to
> use XSLT, but I would want the user to select which element they
> request. In other words, they are given a form with options and that
> form can manipulate the .XSL file.
>
> Now I know it could be done in a lengthly manner by just opening the XSL
> file and manipulating it like fopen or something like that, but is there
> a way to somehow embed the contents of the xml into the php code (like
> using <<< EOF for html), and being able to substitute the template match
> string for a variable ?
>
> Any ideas ?
>
> Thanks Gamesmaster,
> Matt
>
A bit off-topic (since XSLT is not PHP...) but here goes.
First I need to clarify what you are doing -
...
defines the template portion, and that is pretty immutable.
At some point you must have in your XSLT something like
This is the bit you can play with:
so:
Essentially you need to apply the template of any element, but only those whose
name matches your request.
Note that
doesn't work... :(
So now if your PHP does something like
$xslDom = new DOMDocument();
$xslDom->load('matchMe.xsl');
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xslDom);
$xslt->setParameter('','matchMe','umbongo');
$xmlDom = new DOMDocument();
$xmlDom->load('some_document_that_has_an_umbongo_tag.xml');
echo $xslt->transformToXML($xmlDom);
you should get the results of the 'umbongo' template (only)
'f course, this is not tested, but I have used this idea in working code
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Fun with XSLT
am 22.10.2009 17:44:43 von Peter Ford
Matthew Croud wrote:
> Hi Guys,
>
> Well i;ve been slaving on with my PHP XML endeavors and i'm loving it,
> just finishing the meaty parts of my XSLT for dummies book too.
>
> I have a question which asks "is it possible?".
>
> Using XSLT I can collect specific parts of my XML using something sexy
> like . Lets say however, that I need to
> use XSLT, but I would want the user to select which element they
> request. In other words, they are given a form with options and that
> form can manipulate the .XSL file.
>
> Now I know it could be done in a lengthly manner by just opening the XSL
> file and manipulating it like fopen or something like that, but is there
> a way to somehow embed the contents of the xml into the php code (like
> using <<< EOF for html), and being able to substitute the template match
> string for a variable ?
>
> Any ideas ?
>
> Thanks Gamesmaster,
> Matt
>
Despite my other post, of course you can generate the XSL on the fly:
$choice='umbongo';
$xslScript <<
EoXSL
$xslt = new DOMDocument();
$xslt->loadXML($xslScript);
// ... etc...
?>
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: Fun with XSLT
am 22.10.2009 17:49:31 von Matthew Croud
On 22 Oct 2009, at 16:39, Peter Ford wrote:
> Matthew Croud wrote:
>> Hi Guys,
>>
>> Well i;ve been slaving on with my PHP XML endeavors and i'm loving
>> it,
>> just finishing the meaty parts of my XSLT for dummies book too.
>>
>> I have a question which asks "is it possible?".
>>
>> Using XSLT I can collect specific parts of my XML using something
>> sexy
>> like . Lets say however, that I need
>> to
>> use XSLT, but I would want the user to select which element they
>> request. In other words, they are given a form with options and that
>> form can manipulate the .XSL file.
>>
>> Now I know it could be done in a lengthly manner by just opening
>> the XSL
>> file and manipulating it like fopen or something like that, but is
>> there
>> a way to somehow embed the contents of the xml into the php code
>> (like
>> using <<< EOF for html), and being able to substitute the template
>> match
>> string for a variable ?
>>
>> Any ideas ?
>>
>> Thanks Gamesmaster,
>> Matt
>>
> A bit off-topic (since XSLT is not PHP...) but here goes.
>
> First I need to clarify what you are doing -
> ...
> defines the template portion, and that is pretty immutable.
>
> At some point you must have in your XSLT something like
>
> This is the bit you can play with:
>
> so:
>
>
>
>
>
>
>
>
>
>
>
> xsl:template>
>
>
>
>
>
>
>
>
>
> Essentially you need to apply the template of any element, but only
> those whose
> name matches your request.
> Note that
>
> doesn't work... :(
>
> So now if your PHP does something like
>
> $xslDom = new DOMDocument();
> $xslDom->load('matchMe.xsl');
> $xslt = new XSLTProcessor();
> $xslt->importStylesheet($xslDom);
> $xslt->setParameter('','matchMe','umbongo');
> $xmlDom = new DOMDocument();
> $xmlDom->load('some_document_that_has_an_umbongo_tag.xml');
> echo $xslt->transformToXML($xmlDom);
>
> you should get the results of the 'umbongo' template (only)
>
>
> 'f course, this is not tested, but I have used this idea in working
> code
>
>
>
>
> --
> Peter Ford phone: 01580 893333
> Developer fax: 01580 893399
> Justcroft International Ltd., Staplehurst, Kent
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Utter brilliance, this is superb, I might drop you a mail to clarify a
few things later Peter,
but your reply was superb and has given me many options to try out.
Thanks again!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php