Peter & hilz
THANK YOU !!!!!
This came in just in time, spend allmost all night reading a zillion
tutorials. I found the copy and copy-of functions but didn't get them
to work, till now that is..
Have a nice weekend and again Thanks,
Dennis
Peter Flynn wrote:[color=blue]
> hilz wrote:
>[color=green]
> > dennis wrote:[color=darkred]
> >> hilz wrote:
> >>
> >>>>The translation from 'href://www.somewhere.com?id=002' to
> >>>>'href://www.somewhere.com/?var=X&new_id=002' is no problem, i'll be
> >>>>using regular expressions for that.
> >>>
> >>>
> >>>
> >>>So if you're going to be using regular expressions for that, what do you
> >>>want the xslt script to do? Other than this change you indicated above,
> >>>the two trees look identical to me, and would not need any
> >>>transformation after you've done what you wanted using regular
> >>>expressions. Or am i missing something here?
> >>
> >>
> >> Yes your missing the point that they demand it's an xslt file.
> >> The application is alleady written, one of the demands was that it had
> >> the option of applying an external XSLT file, this way the user of the
> >> application had control over the XML the application outputs.
> >> I've build this option succesfully into my application, but know
> >> they're asking if i can deliver the app with one standard *.xsl file
> >> wich does the above.
> >> The problem being i know to little about XSLT.
> >>
> >> The main problem i'm running into here is that most examples on the net
> >> are showing you how to transform the xml entirely. They're not showing
> >> how to keep the original xml only changing one recurring element
> >> (item/c in this case).
> >>
> >> I'm looking for a simple example wich does transform the provided xml,
> >> i can than myself hack the XPATH (those are regeps right?) expressions
> >> in the *.xsl file so it matches my client's needs.
> >>
> >> Hope someone can help,
> >> Dennis
> >>[/color]
> >
> >
> > ok here is a starting point...
> > you can use something like this:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <xsl:stylesheet version="1.0"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > <xsl:output method="xml" indent="yes" omit-xml-declaration="no"
> > version="1.0"/>
> >
> > <xsl:template match="*">
> > <xsl:copy>
> > <xsl:copy-of select="@*"/>
> > <xsl:apply-templates/>
> > </xsl:copy>
> > </xsl:template>
> >
> > <xsl:template match="c">
> > *** here you need to output the transformed href ****
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> >
> >
> >
> > this will bascially copy all elements/attributes, except for the <c>
> > element, where you will need to somehow transform the old href to a new
> > one...
> > so all what you need to do is add some code in the place indicated by
> > this line
> > *** here you need to output the transformed href ****[/color]
>
> ...which would be something like
>
> <xsl:template match="c">
> <c>
> <xsl:value-of select="substring-before(.,'id=')"/>
> <xsl:text>var=X&new_id=</xsl:text>
> <xsl:value-of select="substring-after(.,'id=')"/>
> </c>
> </xsl:template>
>
> No need for any REs, just split the string and insert the new stuff.
>
> ///Peter
> --
> XML FAQ:
http://xml.silmaril.ie/[/color]