home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
WindowsServerTrial
/
server.iso
/
sources
/
install.wim
/
2
/
Windows
/
System32
/
msfeeds.dll
/
HTML
/
RSS1NORMALIZER.XSL
< prev
next >
Wrap
Extensible Markup Language
|
2008-01-19
|
17KB
|
339 lines
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rss="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:msfeednorm="urn:microsoft:feed-normalization"
exclude-result-prefixes="content rdf rss dc dcterms sy msfeednorm"
>
<!-- Shared templates -->
<xsl:import href="res://msfeeds.dll/SharedNormalizer.xsl" />
<!-- Output XML UTF-8 -->
<xsl:output method="xml" encoding="utf-8" />
<!-- Entry point -->
<xsl:template match="/rdf:RDF">
<rss version="2.0">
<channel>
<!-- Build a list of referenced nodes from cf:sort and cf:group -->
<xsl:variable name="cfReferences">
<xsl:call-template name="_BuildCfReferenceList"><xsl:with-param name="value" select="rss:channel" /></xsl:call-template>
</xsl:variable>
<!-- Process feed elements -->
<xsl:apply-templates select="rss:channel" />
<xsl:apply-templates select="rss:image" />
<xsl:apply-templates select="rss:textinput" />
<xsl:apply-templates select="rss:item">
<xsl:with-param name="references" select="$cfReferences" />
</xsl:apply-templates>
</channel>
</rss>
</xsl:template>
<!-- Channel processing -->
<xsl:template match="rss:channel">
<xsl:apply-templates select="*" mode="channel" />
</xsl:template>
<xsl:template match="*" mode="channel">
<xsl:variable name="isFirst">
<xsl:call-template name="_IsFirstChildOfItsKind"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="namespace-uri(.) = $_NSrss and local-name(.) = 'title' and $isFirst = 'true'">
<xsl:call-template name="_OutputTitle"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSrss and local-name(.) = 'link' and $isFirst = 'true'">
<xsl:variable name="linkUrl">
<xsl:call-template name="_CompleteUrl">
<xsl:with-param name="baseUrl" select="$downloadUrl" />
<xsl:with-param name="Url" select="." />
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="_OutputLink"><xsl:with-param name="value" select="$linkUrl" /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSrss and local-name(.) = 'description' and $isFirst = 'true'">
<xsl:call-template name="_OutputTextDescription"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'creator'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputManagingEditor">
<xsl:with-param name="value" select="." />
<xsl:with-param name="convertToAtom" select="'true'" />
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'subject'">
<xsl:call-template name="_OutputCategory"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'publisher'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputWebMaster"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'language'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputLanguage"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'rights'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputCopyright"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdcterms and local-name(.) = 'modified'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../atom:updated)">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'date'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputPubDate"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../dcterms:modified)">
<xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../atom:updated)">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdcterms and local-name(.) = 'available'">
<xsl:if test="$isFirst = 'true' and not(../dc:date) and not(../dcterms:modified)">
<xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../atom:updated)">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdcterms and local-name(.) = 'issued'">
<xsl:if test="$isFirst = 'true' and not(../dc:date) and not(../dcterms:available) and not(../dcterms:modified)">
<xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../atom:updated)">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'published'">
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'updated'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../dc:date) and not(../dcterms:available) and not(../dcterms:modified) and not(../dcterms:issued)">
<xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:when>
<!-- First pair of updateFrequency and updatePeriod gets converted to ttl; all sy:* nodes are preserved as extensions -->
<xsl:when test="namespace-uri(.) = $_NSsy and local-name(.) = 'updatePeriod' and $isFirst = 'true'">
<xsl:if test="../sy:updateFrequency">
<xsl:call-template name="_ConvertUpdatesToTtl">
<xsl:with-param name="updatePeriod" select="string(.)" />
<xsl:with-param name="updateFrequency" select="string(../sy:updateFrequency)" />
</xsl:call-template>
</xsl:if>
<xsl:call-template name="_OutputExtension"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NScf and local-name(.) = 'treatAs'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputCfTreatAs"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NScf and local-name(.) = 'listinfo'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputCfListinfo"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:when>
<!-- Copy extension nodes -->
<xsl:when test="namespace-uri(.) != $_NSrss and namespace-uri(.) != ''">
<xsl:call-template name="_OutputExtension"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- Image processing -->
<xsl:template match="rss:image">
<xsl:if test="position() = 1">
<xsl:variable name="imageUrl">
<xsl:call-template name="_CompleteUrl">
<xsl:with-param name="baseUrl" select="$downloadUrl" />
<xsl:with-param name="Url" select="rss:url" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="imageLink">
<xsl:call-template name="_CompleteUrl">
<xsl:with-param name="baseUrl" select="$downloadUrl" />
<xsl:with-param name="Url" select="rss:link" />
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="_OutputImage">
<xsl:with-param name="url" select="$imageUrl" />
<xsl:with-param name="title" select="rss:title" />
<xsl:with-param name="link" select="$imageLink" />
<xsl:with-param name="subnodesToCopy" select="*[namespace-uri(.) != $_NSrss and namespace-uri(.) != '']" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Text Input processing -->
<xsl:template match="rss:textinput">
<xsl:if test="position() = 1">
<xsl:variable name="linkUrl">
<xsl:call-template name="_CompleteUrl">
<xsl:with-param name="baseUrl" select="$downloadUrl" />
<xsl:with-param name="Url" select="rss:link" />
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="_OutputTextInput">
<xsl:with-param name="title" select="rss:title" />
<xsl:with-param name="name" select="rss:name" />
<xsl:with-param name="link" select="$linkUrl" />
<xsl:with-param name="description" select="rss:description" />
<xsl:with-param name="subnodesToCopy" select="*[namespace-uri(.) != $_NSrss and namespace-uri(.) != '']" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Item processing -->
<xsl:template match="rss:item">
<xsl:param name="references" />
<item>
<xsl:call-template name="_OutputXmlLang"><xsl:with-param name="value" select="@xml:lang" /></xsl:call-template>
<xsl:apply-templates select="* | @*" mode="item">
<xsl:with-param name="references" select="$references" />
</xsl:apply-templates>
</item>
</xsl:template>
<xsl:template match="*" mode="item">
<xsl:param name="references" />
<xsl:variable name="isFirst">
<xsl:call-template name="_IsFirstChildOfItsKind"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="namespace-uri(.) = $_NSrss and local-name(.) = 'title' and $isFirst = 'true'">
<xsl:call-template name="_OutputTitle"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSrss and local-name(.) = 'link' and $isFirst = 'true'">
<xsl:variable name="linkUrl">
<xsl:call-template name="_CompleteUrl">
<xsl:with-param name="baseUrl" select="$downloadUrl" />
<xsl:with-param name="Url" select="." />
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="_OutputLink"><xsl:with-param name="value" select="$linkUrl" /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'creator'">
<xsl:call-template name="_OutputAuthor">
<xsl:with-param name="value" select="." />
<xsl:with-param name="convertToAtom" select="'true'" />
</xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'subject'">
<xsl:call-template name="_OutputCategory"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'date'">
<xsl:if test="$isFirst= 'true'">
<xsl:call-template name="_OutputPubDate"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../atom:published)">
<xsl:call-template name="_OutputAtomPublished"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
<xsl:if test="not(../atom:updated) and not(../dcterms:modified)">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'published'">
<xsl:if test="$isFirst= 'true'">
<xsl:call-template name="_OutputAtomPublished"><xsl:with-param name="value" select="." /></xsl:call-template>
<xsl:if test="not(../dc:date)">
<xsl:call-template name="_OutputPubDate"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'updated'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSdcterms and local-name(.) = 'modified'">
<xsl:if test="$isFirst = 'true'">
<xsl:if test="not(../atom:updated)">
<xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NScontent and local-name(.) = 'encoded'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputDescriptionAndSummary">
<xsl:with-param name="description" select="." />
<xsl:with-param name="descriptionType" select="'html'" />
<xsl:with-param name="descriptionBaseUrl" select="$downloadUrl" />
<xsl:with-param name="summary" select="../rss:description" />
<xsl:with-param name="summaryType" select="'html'" />
<xsl:with-param name="summaryBaseUrl" select="$downloadUrl" />
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSrss and local-name(.) = 'description' and $isFirst = 'true'">
<xsl:if test="not(../content:encoded)">
<xsl:call-template name="_OutputDescription">
<xsl:with-param name="value" select="." />
<xsl:with-param name="type" select="'html'" />
<xsl:with-param name="baseUrl" select="$downloadUrl" />
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSslash and local-name(.) = 'comments'">
<xsl:if test="$isFirst = 'true'">
<xsl:call-template name="_OutputSlashComments"><xsl:with-param name="value" select="." /></xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:when test="namespace-uri(.) = $_NSwfw and (local-name(.) = 'commentRss' or local-name(.) = 'commentRSS')">
<xsl:if test="$isFirst = 'true'">
<xsl:variable name="commentRssUrl">
<xsl:call-template name="_CompleteUrl">
<xsl:with-param name="baseUrl" select="$downloadUrl" />
<xsl:with-param name="Url" select="." />
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="_OutputWfwCommentRSS"><xsl:with-param name="value" select="$commentRssUrl" /></xsl:call-template>
</xsl:if>
</xsl:when>
<!-- Copy extension nodes -->
<xsl:when test="namespace-uri(.) != $_NSrss and namespace-uri(.) != ''">
<xsl:call-template name="_OutputExtension">
<xsl:with-param name="value" select="." />
<xsl:with-param name="references" select="$references" />
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="@*" mode="item">
<!-- No need to check if first, because XML doesn't allow duplicate attributes -->
<xsl:if test="namespace-uri(.) = $_NSrdf and local-name(.) = 'about'">
<xsl:call-template name="_OutputGuid">
<xsl:with-param name="value" select="." />
<xsl:with-param name="isPermaLink" select="'false'" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>