xsl-list
[Top] [All Lists]

AW: [xsl] RSS 2.0 to RSS 1.0 XSLT problem in Luminis 3.3

2006-07-12 09:22:25
Hi Seth,

You are getting transformation, because you are mixing up the XSL
instructions (although the error message seems a bit odd).

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

You need to declare the namespace for the rdf prefix in your
<xsl:stylesheet>, too, since you need it in nearly all of your
templates. 

<xsl:template match="rss">
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
  xmlns="http://purl.org/rss/1.0/";>

  <xsl:template match="channel">
    <channel>
      <xsl:attribute name="rdf:about"><xsl:value-of
select="link"/></xsl:attribute>
      <title><xsl:value-of select="title"/></title>
      <description><xsl:value-of select="description"/></description>
      <image><xsl:attribute name="rdf:resource"><xsl:value-of
select="image"/></xsl:attribute></image>
    <items><rdf:Seq>
        <xsl:for-each select="item">
          <rdf:li>
                <xsl:attribute name="rdf:resource"><xsl:value-of
select="link"/></xsl:attribute>
              </rdf:li>
        </xsl:for-each>
      </rdf:Seq></items>
    <textinput><xsl:value-of select="textinput"/></textinput>
    </channel>
  </xsl:template>

Templates can't be nested in XSLT. If you want to apply templates for
other nodes in an template, use <xsl:apply-templates> instead.
<xsl:template> must be a child element of <xsl:stylesheet>.

  <xsl:transform match="channel/image">
    <image>
      <xsl:attribute name="rdf:resource"><xsl:value-of
select="url"/></xsl:attribute>
        <title><xsl:value-of select="image/title"/></title>
        <url><xsl:value-of select="image/url"/></url>
        <link><xsl:value-of select="image/link"/></link>
    </image>
  </xsl:transform>

<xsl:transform> is a synonym for <xsl:stylesheet> and therefore
completely wrong here. You need to change this to be an <xsl:template
...> and move it one level up in your hierarchy. You should also include
an <xsl:apply-template> in your stylesheet invoking this template...

  <xsl:for-each select="channel/item">
    <item>
        <xsl:attribute name="rdf:about"><xsl:value-of
select="link"/></xsl:attribute>
        <title><xsl:value-of select="title"/></title>
        <link><xsl:value-of select="link"/></link>
        <description><xsl:value-of
select="description"/></description>
      </item>
  </xsl:for-each>

I think you should better include this part somewhere in your channel
template...

  <xsl:transform match="channel/textinput">
    <textinput>
        <xsl:attribute name="rdf:about"><xsl:value-of
select="url"/></xsl:attribute>
        <title><xsl:value-of select="title"/></title>
        <description><xsl:value-of
select="description"/></description>
        <link><xsl:value-of select="link"/></link>
    </textinput>
  </xsl:transform>

This template needs to be under <xsl:stylesheet> as well.

</rdf:RDF>
</xsl:template>

</xsl:stylesheet>

If your source document uses a namespace, you need to take that into
account, too.
I didn't have an appropriate RSS 2.0 document at hand, so I can't give
you more detailed information. If you could provide a simple input
document, I can give you an XSLT doing the job.

I hope this helps.

best regards,
Roman

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>