public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo commit in xml/htdocs/xsl: rdftest.xsl
@ 2008-01-26 10:47 Xavier Neys (neysx)
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Neys (neysx) @ 2008-01-26 10:47 UTC (permalink / raw
  To: gentoo-commits

neysx       08/01/26 10:47:18

  Added:                rdftest.xsl
  Log:
  Bug #204402, try feed with <body> of news item transformed to html

Revision  Changes    Path
1.1                  xml/htdocs/xsl/rdftest.xsl

file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/rdftest.xsl?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/rdftest.xsl?rev=1.1&content-type=text/plain

Index: rdftest.xsl
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns="http://purl.org/rss/1.0/"
	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	xmlns:admin="http://webns.net/mvcb/"
	xmlns:dc="http://purl.org/dc/elements/1.1/">

<!-- Bring in all guide.xsl shebang to apply-templates to the news <body>,
     http://bugs.gentoo.org/204402
-->
<xsl:include href="/xsl/guide.xsl"/>

<xsl:output encoding="UTF-8" method="xml" indent="yes" cdata-section-elements=" p" />

<xsl:template match="/rdffeed">

<rdf:RDF>
	<channel>
		<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>
		<dc:creator>www@gentoo.org</dc:creator>
		<dc:language>en-US</dc:language>
		<admin:errorReportsTo rdf:resource="mailto:www@gentoo.org" />
		<items>
			<rdf:Seq>
				<xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()&lt;11]/text()">
					<rdf:li>
						<xsl:attribute name="rdf:resource">http://www.gentoo.org<xsl:value-of select="." /></xsl:attribute>
					</rdf:li>
				</xsl:for-each>
			</rdf:Seq>
		</items>
	</channel>

	<xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()&lt;11]/text()">
  <xsl:variable name="da-news" select="document(.)"/>
  <xsl:if test="$da-news/news/title">
    <item>
      <xsl:attribute name="rdf:about">http://www.gentoo.org<xsl:value-of select="." /></xsl:attribute>
      <title><xsl:value-of select="$da-news/news/title" /></title> 
      <link>http://www.gentoo.org<xsl:value-of select="." /></link>
      <dc:subject><xsl:value-of select="$da-news/news/@category" /></dc:subject>
      <dc:creator><xsl:value-of select="$da-news/news/poster" /></dc:creator>
      <!-- <dc:date><xsl:value-of select="document(.)/news/date" /></dc:date> -->
      <description>
       <xsl:value-of disable-output-escaping="yes" select="concat('&lt;','![CDATA[')" />
       <xsl:apply-templates select="$da-news/news/body"/>
       <xsl:value-of disable-output-escaping="yes" select="concat(']]', '&gt;')"/>
      </description>
    </item>
  </xsl:if>
	</xsl:for-each>
</rdf:RDF>

</xsl:template>
</xsl:stylesheet>



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gentoo-commits] gentoo commit in xml/htdocs/xsl: rdftest.xsl
@ 2008-01-28 22:22 Xavier Neys (neysx)
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Neys (neysx) @ 2008-01-28 22:22 UTC (permalink / raw
  To: gentoo-commits

neysx       08/01/28 22:22:21

  Modified:             rdftest.xsl
  Log:
  One more test

Revision  Changes    Path
1.2                  xml/htdocs/xsl/rdftest.xsl

file : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/rdftest.xsl?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/rdftest.xsl?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewcvs.py/gentoo/xml/htdocs/xsl/rdftest.xsl?r1=1.1&r2=1.2

Index: rdftest.xsl
===================================================================
RCS file: /var/cvsroot/gentoo/xml/htdocs/xsl/rdftest.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- rdftest.xsl	26 Jan 2008 10:47:17 -0000	1.1
+++ rdftest.xsl	28 Jan 2008 22:22:21 -0000	1.2
@@ -1,58 +1,90 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
-	xmlns="http://purl.org/rss/1.0/"
-	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-	xmlns:admin="http://webns.net/mvcb/"
-	xmlns:dc="http://purl.org/dc/elements/1.1/">
+  xmlns="http://purl.org/rss/1.0/"
+  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+  xmlns:admin="http://webns.net/mvcb/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"
+  xmlns:exslt="http://exslt.org/common"
+  extension-element-prefixes="exslt"
+>
 
 <!-- Bring in all guide.xsl shebang to apply-templates to the news <body>,
      http://bugs.gentoo.org/204402
 -->
 <xsl:include href="/xsl/guide.xsl"/>
 
-<xsl:output encoding="UTF-8" method="xml" indent="yes" cdata-section-elements=" p" />
+<xsl:output encoding="UTF-8" method="xml" indent="yes" cdata-section-elements="description" />
+
 
 <xsl:template match="/rdffeed">
 
 <rdf:RDF>
-	<channel>
-		<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>
-		<dc:creator>www@gentoo.org</dc:creator>
-		<dc:language>en-US</dc:language>
-		<admin:errorReportsTo rdf:resource="mailto:www@gentoo.org" />
-		<items>
-			<rdf:Seq>
-				<xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()&lt;11]/text()">
-					<rdf:li>
-						<xsl:attribute name="rdf:resource">http://www.gentoo.org<xsl:value-of select="." /></xsl:attribute>
-					</rdf:li>
-				</xsl:for-each>
-			</rdf:Seq>
-		</items>
-	</channel>
+  <channel>
+    <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>
+    <dc:creator>www@gentoo.org</dc:creator>
+    <dc:language>en-US</dc:language>
+    <admin:errorReportsTo rdf:resource="mailto:www@gentoo.org" />
+    <items>
+      <rdf:Seq>
+        <xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()&lt;11]/text()">
+          <rdf:li>
+            <xsl:attribute name="rdf:resource">http://www.gentoo.org<xsl:value-of select="." /></xsl:attribute>
+          </rdf:li>
+        </xsl:for-each>
+      </rdf:Seq>
+    </items>
+  </channel>
 
-	<xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()&lt;11]/text()">
+  <xsl:for-each select="document('/dyn/news-index.xml')/uris/uri[position()&lt;11]/text()">
   <xsl:variable name="da-news" select="document(.)"/>
   <xsl:if test="$da-news/news/title">
     <item>
       <xsl:attribute name="rdf:about">http://www.gentoo.org<xsl:value-of select="." /></xsl:attribute>
-      <title><xsl:value-of select="$da-news/news/title" /></title> 
+      <title><xsl:value-of select="$da-news/news/title" /></title>
       <link>http://www.gentoo.org<xsl:value-of select="." /></link>
       <dc:subject><xsl:value-of select="$da-news/news/@category" /></dc:subject>
       <dc:creator><xsl:value-of select="$da-news/news/poster" /></dc:creator>
       <!-- <dc:date><xsl:value-of select="document(.)/news/date" /></dc:date> -->
+      <xsl:variable name="xmlnews"><xsl:apply-templates select="$da-news/news/body"/></xsl:variable>
+      <xsl:variable name="txtnews"><xsl:apply-templates select="exslt:node-set($xmlnews)" mode="txtnews"/></xsl:variable>
       <description>
-       <xsl:value-of disable-output-escaping="yes" select="concat('&lt;','![CDATA[')" />
-       <xsl:apply-templates select="$da-news/news/body"/>
-       <xsl:value-of disable-output-escaping="yes" select="concat(']]', '&gt;')"/>
+       <xsl:value-of disable-output-escaping="yes" select="normalize-space($txtnews)"/>
       </description>
     </item>
   </xsl:if>
-	</xsl:for-each>
+  </xsl:for-each>
 </rdf:RDF>
 
 </xsl:template>
+
+<xsl:template match="node()" mode="txtnews">
+  <xsl:choose>
+   <xsl:when test="self::text()">
+     <xsl:value-of disable-output-escaping="yes" select="."/>
+   </xsl:when>
+   <xsl:when test="self::*">
+    <xsl:text disable-output-escaping="yes">&lt;</xsl:text><xsl:value-of select="name(.)"/>
+    <xsl:apply-templates select="@*" mode="txtnews"/>
+    <xsl:text disable-output-escaping="yes">&gt;</xsl:text>
+    <xsl:apply-templates mode="txtnews"/>
+    <xsl:text disable-output-escaping="yes">&lt;/</xsl:text><xsl:value-of select="name(.)"/><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
+   </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="@class | @style" mode="txtnews"/>
+
+<xsl:template match="@*" mode="txtnews">
+  <xsl:value-of select="concat(' ', name(.))"/><xsl:text>=</xsl:text>
+  <xsl:text>"</xsl:text>
+  <xsl:choose>
+    <xsl:when test="name(.)='href' and starts-with(., '/')"><xsl:value-of select="concat('http://www.gentoo.org', .)"/></xsl:when>
+    <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
+  </xsl:choose>
+  <xsl:text>"</xsl:text>
+</xsl:template>
+
 </xsl:stylesheet>



-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-28 22:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-26 10:47 [gentoo-commits] gentoo commit in xml/htdocs/xsl: rdftest.xsl Xavier Neys (neysx)
  -- strict thread matches above, loose matches on Subject: below --
2008-01-28 22:22 Xavier Neys (neysx)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox