[thelist] Using php to transform xml

Chris Price chris.price at choctaw.co.uk
Fri May 25 17:44:07 CDT 2012


Thanks David

I figured there were a few ways of achieving it but getting it working by
this method is a great step forward and inspires me to make further
progress. Thanks for the help. Its greatly appreciated.

--
Chris

On 25 May 2012 19:14, David Miller <dmiller at mcc.ca> wrote:

> There's more than one way to do it, of course, but what you're looking for
> is the <xsl:attribute> element. Here's an example:
>
> <xsl:stylesheet version="1.0" xmlns:xsl="
> http://www.w3.org/1999/XSL/Transform">
>        <xsl:output method="html" version="1.0" encoding="UTF-8"
> indent="yes"/>
>        <xsl:template match="plan">
>                <h1>Planner</h1>
>                <xsl:apply-templates select="task"/>
>        </xsl:template>
>        <xsl:template match="task">
>                <div>
>                        <xsl:attribute name="class"><xsl:value-of
> select="status"/></xsl:attribute>
>                         <span class='title'><xsl:value-of
> select="title"/></span>
>                        <span class='description'><xsl:value-of
> select="description"/></span>
>                        <span class='notes'><xsl:value-of
> select="notes"/></span>
>                </div>
>         </xsl:template>
> </xsl:stylesheet>
>
> ======================================================================
> David R. Miller
> Manager, Software Development / Gestionnaire, Élaboration de logiciels
> Information Technology / Services informatiques
> MEDICAL COUNCIL OF CANADA / LE CONSEIL MÉDICAL DU CANADA
> Tel. / Tél. : (613) 521-6012 ext. / poste 2265
> Fax / Téléc. : (613) 521-9417
> Email / Courriel : dmiller at mcc.ca
> www.mcc.ca
>
> >Hi there
> >
> >I know I should probably do a proper course on xml and xslt but I just
> need
> >a really quick solution for this small job - then I can probe further.
> >
> >I have an xml file with nested tasks:
> >
> ><plan>
> ><task>
> >  <title>Walk</title>
> >  <status>prop</status>
> >  <description>Learn to walk</description>
> >  <notes>Gaining strength and balance</notes>
> ></task>
> >
> >I want to output xhtml so that each task has a container with a class
> >equivalent to its 'status', eg. <div
> >class='prop'><title/><description/><notes/></div>
> >
> >This is a snippet of my xsl file:
> >
> ><h1>Planner</h1>
> ><xsl:for-each select="plan/task">
> ><div>
> ><span><xsl:value-of select="status" /></span>
> ><span class='title'><xsl:value-of select="title" /></span>
> ><span class='description'><xsl:value-of select="description" /></span>
> ><span class='notes'><xsl:value-of select="notes" /></span>
> ></div>
> ></xsl:for-each>
> >
> >I don't want a 'status' span, I want it to be the class of the div.
> >
> >Does this make sense and is there a relatively simple solution?
> >
> >Thanks
> >
> >Chris.Price
> >@Choctaw.co.uk <http:\\choctaw.co.uk>
> >0777 629 0227
>
>
>
> This email may contain privileged and/or confidential information, and the
> Medical Council of Canada does not waive any related rights. Any
> distribution, use, copying or disclosure of this email or the information
> it contains by other than the intended recipient is strictly prohibited. If
> you received this email in error please delete it immediately from your
> system and notify the sender promptly by email that you have done so. The
> integrity and security of this message cannot be guaranteed on the
> Internet.  If you prefer not to receive MCC communications by e-mail,
> please send us an e-mail with only “unsubscribe” in the subject line to
> unsubscribe at mcc.ca.  Any questions about our privacy practices should be
> made in writing and directed to the Privacy Committee at 2283 St. Laurent
> Blvd., Ottawa ON K1G 3H7.
>
> Le présent courriel peut contenir de l'information privilégiée ou
> confidentielle. Le Conseil médical du Canada ne renonce pas aux droits qui
> s'y rapportent. Toute diffusion, utilisation ou copie de ce courriel ou des
> renseignements qu'il contient par une personne autre que le ou les
> destinataires désignés est interdite. Si vous recevez ce courriel par
> erreur, veuillez le supprimer immédiatement et envoyer sans délai à
> l'expéditeur un message électronique pour l'aviser que vous avez éliminé de
> votre ordinateur toute copie du courriel reçu. L'intégrité et la sécurité
> de ce message ne peuvent pas être garanties sur l'Internet.  Si vous ne
> voulez pas que le CMC communique avec vous par courriel, vous pouvez nous
> faire parvenir un courriel à l’adresse suivante unsubscribe at mcc.ca et
> inscrire dans la ligne d’objet « désabonnement ».   Si vous avez des
> questions ou des préoccupations concernant notre politique sur la
> protection des renseignements personnels, n'hésitez pas à en faire part par
> écrit au comité de protection des renseignements personnels, au 2283, boul.
> St-Laurent, Ottawa (Ontario) K1G 3H7.
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !


More information about the thelist mailing list