Commit ba503d50 authored by Aurel's avatar Aurel

modify xslt :

- now it parses georss data if present
- remove useless parameter
- make portal type a parameter

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32309 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a4952d1a
...@@ -32,16 +32,18 @@ ...@@ -32,16 +32,18 @@
<?xml version="1.0" encoding="utf-8"?>\n <?xml version="1.0" encoding="utf-8"?>\n
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \n <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \n
xmlns:md5="http://exslt.org/crypto" exclude-result-prefixes="md5"\n xmlns:md5="http://exslt.org/crypto" exclude-result-prefixes="md5"\n
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"\n
xmlns:georss="http://www.georss.org/georss"\n
xmlns:atom="http://www.w3.org/2005/Atom"\n
xmlns:dc="http://purl.org/dc/elements/1.1/">\n xmlns:dc="http://purl.org/dc/elements/1.1/">\n
\n \n
<xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>\n <xsl:output method="xml" indent="yes" omit-xml-declaration="no"/>\n
\n \n
<!--Parameters list-->\n <!--Parameters list-->\n
<xsl:param name="rid" select="None"/>\n
<xsl:param name="sid" select="None"/>\n
<xsl:param name="categories_list" select="None"/>\n <xsl:param name="categories_list" select="None"/>\n
<xsl:param name="subject_list" select="None"/>\n <xsl:param name="subject_list" select="None"/>\n
<xsl:param name="actor" select="None"/>\n <xsl:param name="actor" select="None"/>\n
<xsl:param name="portal_type" select="None"/>\n
\n \n
<!--Template matching the erp5 Tag-->\n <!--Template matching the erp5 Tag-->\n
<xsl:template match="/">\n <xsl:template match="/">\n
...@@ -62,13 +64,12 @@ xmlns:dc="http://purl.org/dc/elements/1.1/">\n ...@@ -62,13 +64,12 @@ xmlns:dc="http://purl.org/dc/elements/1.1/">\n
</xsl:choose>\n </xsl:choose>\n
</xsl:variable>\n </xsl:variable>\n
<xsl:variable name="converted_id" select="md5:md5($md5_id)"/>\n <xsl:variable name="converted_id" select="md5:md5($md5_id)"/>\n
<object id="{$converted_id}" portal_type="RSS Item">\n <object id="{$converted_id}">\n
<id type="string"><xsl:value-of select="$converted_id"/></id>\n <portal_type type="string"><xsl:value-of select="$portal_type"/></portal_type>\n
<rid type="string"><xsl:value-of select=\'$rid\'/></rid>\n
<categories_list type="tokens"><xsl:value-of select="$categories_list"/></categories_list>\n <categories_list type="tokens"><xsl:value-of select="$categories_list"/></categories_list>\n
<title type="string"><xsl:value-of select="*[local-name() = \'title\']"/></title>\n <title type="string"><xsl:value-of select="*[local-name() = \'title\']"/></title>\n
<subject_list type="lines"><xsl:value-of select="$subject_list"/></subject_list>\n <subject_list type="lines"><xsl:value-of select="$subject_list"/></subject_list>\n
<description type="text"><xsl:value-of select="description|dc:description|*[local-name() = \'content\']"/><xsl:apply-templates select=\'summary\'/></description>\n <description type="text"><xsl:value-of select="description|dc:description|*[local-name() = \'content\']"/><xsl:apply-templates select="summary"/></description>\n
<url_text>\n <url_text>\n
<xsl:choose>\n <xsl:choose>\n
<xsl:when test="link"><xsl:value-of select="link"/></xsl:when>\n <xsl:when test="link"><xsl:value-of select="link"/></xsl:when>\n
...@@ -85,12 +86,20 @@ xmlns:dc="http://purl.org/dc/elements/1.1/">\n ...@@ -85,12 +86,20 @@ xmlns:dc="http://purl.org/dc/elements/1.1/">\n
<state type="string">current</state>\n <state type="string">current</state>\n
<time type="date"><xsl:value-of select="pubDate|dc:date"/></time>\n <time type="date"><xsl:value-of select="pubDate|dc:date"/></time>\n
</workflow_action>\n </workflow_action>\n
<xsl:apply-templates select=".//geo:lat"/>\n
<xsl:apply-templates select=".//geo:long"/>\n
</object>\n </object>\n
</xsl:template>\n </xsl:template>\n
<xsl:template match="geo:lat">\n
<latitude type="string"><xsl:value-of select="."/></latitude>\n
</xsl:template>\n
<xsl:template match="geo:long">\n
<longitude type="string"><xsl:value-of select="."/></longitude>\n
</xsl:template> \n
<xsl:template match="summary">\n <xsl:template match="summary">\n
<xsl:apply-templates/>\n <xsl:value-of select="."/>\n
</xsl:template>\n </xsl:template>\n
\n \n
</xsl:stylesheet>\n </xsl:stylesheet>\n
......
...@@ -62,8 +62,7 @@ from DateTime import DateTime\n ...@@ -62,8 +62,7 @@ from DateTime import DateTime\n
from AccessControl import getSecurityManager\n from AccessControl import getSecurityManager\n
\n \n
#Step1: transform an RSS Feed into ERP5 XML\n #Step1: transform an RSS Feed into ERP5 XML\n
#xsl_kw = {\'date\':DateTime()}\n xsl_kw = {\'actor\':getSecurityManager().getUser().getId(), \'portal_type\' : \'RSS Item\'}\n
xsl_kw = {\'actor\':getSecurityManager().getUser().getId()}\n
xml_output = context.TextDocument_asCallable.RSSFeed_asAggregatedImportXML(**xsl_kw)\n xml_output = context.TextDocument_asCallable.RSSFeed_asAggregatedImportXML(**xsl_kw)\n
\n \n
#Step2: extract xml subobjects and create RSS Item objects\n #Step2: extract xml subobjects and create RSS Item objects\n
......
211 213
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment