Re: [xsl] Newbie XSL Question -- Setting up XSLT with XML file

Subject: Re: [xsl] Newbie XSL Question -- Setting up XSLT with XML file
From: "Glenn MacGregor" <gtm@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Feb 2004 10:30:33 -0500
Thanks for the info.

You are correct, I want the CDATA of the title tag (<title>?</title>) I
would want '?' in that case.

I list of devices (in this case) comes from a database query, that is where
the php comes from. I idea around the <hsn:foreach> construct is to loop
through the list and copy everything in-between the open <hsn:foreach> and
the close </hsn:foreach> count number of times (count is the number of
elements in the list). Replacing any occurrence of <hsn:variable> with the
value of the current element in the list.

Is it possible to create another file with the output of the database query
and use that somehow?

    Thanks

----- Original Message -----
From: <christof.hoeke@xxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, February 18, 2004 9:01 AM
Subject: AW: [xsl] Newbie XSL Question


> hi,
> you do not need to do any intermediate (php) processing. an xsl template
should be easy
>
> something like:
>
> define namespace hsn in
> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:hsn="whatever your
namespace is">
>
> template for hsn:replace
> <xsl:template match="hsn:replace">
> WHAT YOU WANT TO OUTPUT e.g.
> <xsl:element name="@name">?</xsl:element>
> </xsl:template>
>
> but what i do not yet understand is where the content of the to be created
elements comes from:
>
> <hsn:replace
> with="tag">title</hsn:replace>
>
> should get
>
> <title>?</title>
>
>
> <hsn:foreach param="devices">
> <tr><td><hsn:var name="devices"/></td></tr>
> </hsn:foreach>
>
> should get
>
> <tr><td>test1</td></tr>
> <tr><td>test2</td></tr>
> <tr><td>test3</td></tr>
>
> where does "test" come from? and you need somewhere the info how many
devices there are, don't you?
>
>
> is there another config file for the missing infos or am i missing
something...
>
> thanks
> chris
>
>
> -----Ursprüngliche Nachricht-----
> Von: Glenn MacGregor [mailto:gtm@xxxxxxxxxxxxxxxxxxxxxx]
> Gesendet: Mittwoch, 18. Februar 2004 14:49
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: [xsl] Newbie XSL Question
>
>
> Hi All,
>
> I have searched the newsgroup archives and not found anything relevant to
my
> question, so here goes...
>
> I am writing a php report generation application that will take an xml
file
> as input, substitute some real variables for placeholders and create the
> report. I was thinking of using xsl to help me with this task. Here is
what
> I have so far:
>
> XML Config file:
> <html>
> <head><title>Test Title</title></head>
> <body><table><tr><td colspan="2"><hsn:replace
> with="tag">title</hsn:replace></td></tr>
> <hsn:foreach param="devices">
> <tr><td><hsn:var name="devices"/></td></tr>
> </hsn:foreach>
> </body>
> </html>
>
> So in the html (xml) I have tow tags <hsn:replace> and <hsn:foreach>.
>
> The <hsn:replace> is used to replace the complete ("<hsn:replace
> with="tag">title</hsn:replace>") tag with the CDATA of the tag defined in
> the hsn:replace CDATA. So replace the complete hsn:replace tag with "Test
> Title".
>
> The <hsn:foreach> tag is used to iterate over a list of things(devices in
> this case) and substitute the current one in the CDATA of the hsn:foreach
> tag. So if there were 3 devices(test1,test2,test3) the output I would like
> would be:
>
> <tr><td>test1</td></tr>
> <tr><td>test2</td></tr>
> <tr><td>test3</td></tr>
>
> for that section.
>
> Do you think XSL could help me in any of these tasks? I assume I will have
> my php scripts write some intermediate output (xml) in which the hsn:*
tags
> a changed to something more useful for XSL. Then run the intermediate file
> through the XSL processor w/ a stylesheet to get the final output.
>
> Is any of this possible?
>
>     Thanks so much for your input!
>
>             Glenn
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread