Subject: Re: [xsl] Re: XML Feed Transformation From: "Eric Bréchemier" <eric.brechemier@xxxxxxxxx> Date: Tue, 16 Oct 2007 12:41:46 +0200 |
I used Kernow 1.5.2 beta b2 + Saxon-B 8.9.0.4 to test your example. I fixed the following errors to have your example work....... For those interested only in the relevant answer, you can jump directly to point 7. 1. Missing closing </p> in sample XSL Error on line 29 column 58 of file:/home/enz/projects/sandbox/feed.xsl: SXXP0003: Error reported by XML parser: The element type "p" must be terminated by the matching end-tag "</p>". replaced </clxml:url><p/> with </clxml:url></p> 2. Unescaped '&' in attribute value of sample XML Error on line 12 column 61 of file:/home/enz/projects/sandbox/input.xml: SXXP0003: Error reported by XML parser: The reference to entity "f" must end with the ';' delimiter. Replaced & with & 3. Same error on line 15 and 19 of sample XML you now have link="index_one.pl?c=dia&f=dia_1400_2" link="index_one.pl?c=dia&f=dia_1400_1" link="index_one.pl?c=dia&f=dia_fbem" 4. Missing '<' in start-tag line 21 Error on line 24 column 3 of file:/home/enz/projects/sandbox/input.xml: SXXP0003: Error reported by XML parser: The element type "sport1-ml" must be terminated by the matching end-tag "</sport1-ml>". Replaced element name="link" link="http://wap.one.at/fussball_euro2008" imagename=""> with <element name="link" link="http://wap.one.at/fussball_euro2008" imagename=""> 5. The sample is now running, with result <?xml version="1.0" encoding="UTF-8"?><clxml:page xmlns:clxml="changingworlds.com/clxml" level="1"><clxml:content url="test" recs="false" level="1" nodeid="tmpSportPage" title="Diashows"><clxml:text href=""><clxml:bold/><clxml:lineBreak/><label>Und wieder jubeln am Ende die anderen ...</label><clxml:lineBreak/></clxml:text><clxml:custom property="pageType" value="sportMenuPage"/></clxml:content></clxml:page> 6. Now I try to understand the issue you mention: > Everything works fine except image is <element image='' imagename=''> > is not transformed for some reason. I dont understand what exactly is > missing? It seems that by <element image='' imagename=''> you refer to <element name="image" imagename="http://webat1.sport1.at/one/out/img/dia/dia_1400_1.jpg"/> since this is the only "element" with occurrences of both "image" and "imagename". 7. THE ANSWER: imagename is an attribute not a child element, thus <xsl:attribute name="href"><xsl:value-of select="/sport1-ml/element[(@name='image')]/imagename"/></xsl:attribute> should be rewritten <xsl:attribute name="href"><xsl:value-of select="/sport1-ml/element[(@name='image')]/@imagename"/></xsl:attribute> Then you get <?xml version="1.0" encoding="UTF-8"?><clxml:page xmlns:clxml="changingworlds.com/clxml" level="1"><clxml:content url="test" recs="false" level="1" nodeid="tmpSportPage" title="Diashows"><clxml:text href="http://webat1.sport1.at/one/out/img/dia/dia_1400_1.jpg"><clxml:bold/><c lxml:lineBreak/><label>Und wieder jubeln am Ende die anderen ...</label><clxml:lineBreak/></clxml:text><clxml:custom property="pageType" value="sportMenuPage"/></clxml:content></clxml:page> where <clxml:text href=""> is now <clxml:text href="http://webat1.sport1.at/one/out/img/dia/dia_1400_1.jpg"> ------------------------------------------------ Verdict: your sample XML does not run with your sample XSL. I strongly advise that you provide only tested XML and XSL samples in your requests :) This will let people on this list spend more time on your problem and less time in guessing and investigations... A second piece of advice: you should rewrite your XSL using a combination of <xsl:apply-templates select="..." /> and <xsl:template match="..."> instead of using the "for-each" style in a single global template. Kind Regards, Eric Brichemier My professional charges are upon a fixed scale. I do not vary them, save when I remit them altogether. -- Sherlock Holmes, The Problem of Thor Bridge On 10/16/07, Zulfikar Dholkawala <zulfikarmd@xxxxxxxxx> wrote: > Hi all, > I have following Feed which I want to transform. > > <sport1-ml> > <CHARGED/> > <element name="head"/> > <element name="title" imagename="diashows.jpg"> > <title>Diashows</title> > </element> > <element name="image" > imagename="http://webat1.sport1.at/one/out/img/dia/dia_1400_1.jpg"/> > <element name="text"> > <label>Und wieder jubeln am Ende die anderen ...</label> > </element> > <element name="link" imagename="" link="index_one.pl?c=dia&f=dia_1400_2"> > <label>Ndchstes Bild</label> > </element> > <element name="link" imagename="" link="index_one.pl?c=dia&f=dia_1400_1"> > <label>Vorheriges Bild</label> > </element> > <element name="spacer"/> > <element name="link" link="index_one.pl?c=dia&f=dia_fbem"> > <label>Diashows</label> > </element> > element name="link" link="http://wap.one.at/fussball_euro2008" imagename=""> > <label>EURO 2008</label> > </element> > <element name="homelink"/> > <element name="footer"/> > </sport1-ml> > > > I have following XSL for transformation: > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:clxml="changingworlds.com/clxml"> > <xsl:template match="/"> > <clxml:page level="1"> > <clxml:content url="test" recs="false" level="1" nodeid="tmpSportPage"> > <xsl:attribute name="title"><xsl:value-of > select="/sport1-ml/element[(@name='title')]/title"/></xsl:attribute> > <clxml:text> > > <xsl:for-each select="/sport1-ml/element"> > <xsl:if test="@name = 'image'"> > <xsl:attribute name="href"><xsl:value-of > select="/sport1-ml/element[(@name='image')]/imagename"/></xsl:attribute> > </xsl:if> > <xsl:if test="@name = 'link'"> > <!--<xsl:choose>--> > <xsl:if test="label = 'Aktualisieren' or label = 'Frühere > Kommentare' or label = 'Renndetails' or label = 'Rennen' or label = > 'Startaufstellung' or label = 'Qualifikation'"> > <p><clxml:url> > <xsl:attribute name="href"><xsl:value-of > select="concat('sport1', > substring-after(@link,'?'))"/></xsl:attribute> > <xsl:value-of select="label"/> > </clxml:url><p/> > > </xsl:if> > </xsl:if> > <xsl:if test="@name = 'text'"> > <clxml:bold> > <xsl:value-of select="title"/> > </clxml:bold> > <xsl:if test="label"> > <clxml:lineBreak/> > <xsl:copy-of select="label"/> > </xsl:if> > <clxml:lineBreak/> > </xsl:if> > </xsl:for-each> > </clxml:text> > <clxml:custom property="pageType" value="sportMenuPage"/> > </clxml:content> > </clxml:page> > </xsl:template> > </xsl:stylesheet> > > Everything works fine except image is <element image='' imagename=''> > is not transformed for some reason. I dont understand what exactly is > missing? > > Can someone guide me? Thanks. > > ZM
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: XML Feed Transformation, Zulfikar Dholkawala | Thread | Re: [xsl] Re: XML Feed Transformati, Andrew Welch |
[xsl] Re: XML Feed Transformation, Zulfikar Dholkawala | Date | Re: [xsl] Re: XML Feed Transformati, Andrew Welch |
Month |