????

Your IP : 216.73.216.152


Current Path : C:/Windows/System32/en-US/
Upload File :
Current File : C:/Windows/System32/en-US/Windows.Web.dll.mui

MZ����@���	�!�L�!This program cannot be run in DOS mode.

$��<߱�R���R���R�U�����R�U�P���R�Rich��R�PEL�!�

��!@ <�8.rdata�@@.rsrc� �@@@�*6
T88@�*6$��8.rdata8x.rdata$zzzdbg p.rsrc$01p#0�.rsrc$02 �]U�l�	�F�b�1��=�·���A@�*6��8�P�x�������r��T�U(�@�X���p������������>���	�	�			(	8	H	X	h	x	�h#�� $$�D&(�l*��h10P�����,��T����V��0MH�(y)u�T����MUIATOM03NORMALIZER.XSLATOM1NORMALIZER.XSLRSS1NORMALIZER.XSLRSS2NORMALIZER.XSLSHAREDNORMALIZER.XSL���茘{��|<[+<�xG�k#G��(�3�Km���MUIen-US'%1': Value must not be empty.N'%1': Buffer does not have enough space to hold the requested number of bytes.'%1': Invalid characters found.Invalid HTTP headers.Invalid HTTP response status.E'%1': Provided value is not an ignorable ChainValidationResult value.!'%1': Only Atom 1.0 is supported..'%1': Only Atom 1.0 and RSS 2.0 are supported.FOnly Atom 0.3, Atom 1.0, RSS 0.91, RSS 0.92 and RSS 2.0 are supported.'%1': Specify EditUri property.+The length of the response content is zero.6Credentials cannot be changed after sending a request.2The '%1' element is missing required element '%2'.4The '%1' element is missing required attribute '%2'.Missing '%1' root element..The '%1' element does not have child elements.Duplicate element '%1'.*Unexpected '%1' attribute on element '%2'.CThis is not a string value. Use ValueType property to get the type.CThis is not a number value. Use ValueType property to get the type.DThis is not a boolean value. Use ValueType property to get the type.CThis is not an array value. Use ValueType property to get the type.DThis is not an object value. Use ValueType property to get the type.ETo get a string value from an object use the GetNamedString() method.ETo get a number value from an object use the GetNamedNumber() method.GTo get a boolean value from an object use the GetNamedBoolean() method.DTo get an array value from an object use the GetNamedArray() method.ATo get a string value from an array use the GetStringAt() method.ATo get a number value from an array use the GetNumberAt() method.CTo get a boolean value from an array use the GetBooleanAt() method.BTo get an object value from an array use the GetObjectAt() method.PAd00�
0#0PP�pp`����G�����+API

AtomPub

JSON

Format

(AsyncOperation

HTTP

Info

API Enter

API Exit

4Async operation start

<Async operation complete

8Async operation failure

4Async operation abort

4Async operation close

@Async operation completion

<Async operation progress

(HTTP operation

8Parse category document

8Check required element

<Check required attribute

<Check duplicated element

Parse URI

8Parse date time string

$Parse integer

Parse XML

8Check custom attribute

4Check custom element

,Parse JSON string

,Add default value

(Add first value

<Ignore unexpected content

4Add custom attribute

0Add custom element

Error

Warning

 Information

Verbose

APIs

Parse

Serialize

Async I/O

LMicrosoft-Windows-Runtime-WebAPI

LAsync operation %1 at %2 started.

�Async operation %1 at %2 failed to start. The error code is %3: %4

lAsync operation %1 at %2 completed successfully.

xAsync operation %1 at %2 failed with error code %3: %4.

XAsync operation %1 at %2 was cancelled.

TAsync operation %1 at %2 was closed.

�Async operation %1 at %2 called completion callback at %3.

|Async operation %1 at %2 called progress callback at %3.

�Async operation %1 at %2 failed to remove handler from GIT. The error code is %3: %4

�Async operation %1 at %2 failed to register handler at GIT. The error code is %3: %4

�Async operation %1 at %2 failed to retrieve handler from GIT. The error code is %3: %4

<Failed to parse URI '%1'.

�Failed to create URI with base URI '%1' and relative URI '%2'.

<Add HTTP header '%1: %2'.

lStart to connect to '%1' with credential of '%2'.

lStart to connect to '%1' with default credential.

�Failed to connect to '%1' at port %2. The last error is %3: %4

hOpening request to '%1' to '%2' with flags %3.

|Failed to open request to '%1'. The last error is %2: %3

lRequest context %1 has request handle %2 to '%3'.

�Set HTTP send and receive timeout to %2ms on request handle %1.

�Start to send to request handle %1 with content length %2.

`Request handle %1 completed synchronously.

lRequest context %1 completed send asynchronously.

XWriting %2 bytes to request handle %1.

�Failed to send entity body to request handle %1. The last error is %2: %3

`Sent HTTP request at request handle %1: %2

lStart to receive response from request handle %1.

�Received HTTP response from request handle %1 with status code %2 and status description '%3'.

lReceive HTTP response from request handle %1: %2

�Failed to receive HTTP response from request handle %1. The last error is %2: %3

�Request context %1 received HTTP response of %2 bytes, which is over the %3 limit.

`Request context %1 resubmiting the request.

hReusing the request handle %1 for server '%2'.

HRequest context %1 was aborted.

�Progress to '%1': %2 bytes sent; %3 total bytes to send; %4 bytes received; %5 total bytes to receive.

|HTTP request to '%1' completed. The error code is %2: %3

�Async operation %1 at %2 failed to process HTTP response '%3'. The error code is %4: %5

,%1::%2 is called.

D%1::%2 returned successfully.

L%1::%2 failed with HRESULT %3: %4

dStart downloading category document at '%1'.

pCategory document downloaded successfully at '%1'.

�Failed to download category document at '%1'. The error code is %2: %3

�Failed to download category document at '%1'. The HTTP status code was %2.

�Failed to parse category document downloaded from '%1'. The error code is %2: %3.

LRequired element '%1' is missing.

pRequired attribute '%1' is missing on element '%2'.

HDuplicated element '%1' found.

�Required element '%1' is missing. Add one with default value.

�Required attribute '%1' is missing on element '%2'. Add it with empty value.

�The parsed 'feed' element does not have an 'author' element.

�Multiple '%1' elements are found. Use the first and ignore the rest.

tIgnore the 'entry' element found in 'source' element.

�The 'entry' element does not have a 'content' element or a 'link' element with rel='alternate'. Element XML: %1

�The 'item' element is missing both 'title' and 'description' elements. Element XML: %1

�The 'link' element with rel='enclosure' is missing 'length' attribute. Element XML: %1

|Unexpected child element is found in element with XML: %1

�Unexpected 'type' attribute '%1' when 'src' attribute is present. Element XML: %2

�Unexpected 'type' attribute '%1' in Atom text content. Only 'text', 'html' or 'xhtml' is allowed. Element XML: %2

�Element '%1' should not contain child element or text. Element XML: %2

�Atom text content with type='xhtml' must have a single child element 'div' in namespace 'http://www.w3.org/1999/xhtml'.

HFailed to parse date time '%1'.

DFailed to parse integer '%1'.

HFailed to parse document: '%1'.

�Failed to create attribute node. The attribute '%1' in namespace '%2' is not a valid XML attribute.

�Failed to create element node. The element '%1' in namespace '%2' is not a valid XML element.

�Failed to add attribute '%1' in namespace '%2' in to the element. This may be caused by namespace conflict and may be resolved by setting a different namespace prefix on the attribute name.

�Failed to parse JSON string '%1'. The error happened near %2.

xThe JSON string exceeded the maximum allowed depth %1.

@Handle %1: HTTP/2 enabled.

4SyndicationAttribute

DISyndicationAttributeFactory

(SyndicationNode

8ISyndicationNodeFactory

4SyndicationGenerator

DISyndicationGeneratorFactory

(SyndicationText

8ISyndicationTextFactory

0SyndicationContent

@ISyndicationContentFactory

(SyndicationLink

8ISyndicationLinkFactory

,SyndicationPerson

<ISyndicationPersonFactory

0SyndicationCategory

@ISyndicationCategoryFactory

(SyndicationItem

8ISyndicationItemFactory

(SyndicationFeed

8ISyndicationFeedFactory

4RetrieveFeedOperation

,SyndicationClient

<ISyndicationClientFactory

JsonValue

 JsonObject

0IJsonObjectFactory

JsonArray

,IJsonArrayFactory

0ResourceCollection

Workspace

(ServiceDocument

LRetrieveServiceDocumentOperation

8CreateResourceOperation

<RetrieveResourceOperation

8UpdateResourceOperation

8DeleteResourceOperation

HRetrieveMediaResourceOperation

$AtomPubClient

4IAtomPubClientFactory

get_Name

put_Name

$get_Namespace

$put_Namespace

get_Value

put_Value

@CreateSyndicationAttribute

$get_NodeName

$put_NodeName

,get_NodeNamespace

,put_NodeNamespace

$get_NodeValue

$put_NodeValue

$get_Language

$put_Language

 get_BaseUri

 put_BaseUri

8get_AttributeExtensions

4get_ElementExtensions

(GetXmlDocument

4CreateSyndicationNode

get_Text

put_Text

get_Uri

put_Uri

 get_Version

 put_Version

@CreateSyndicationGenerator

get_Type

put_Type

get_Xml

put_Xml

ToString

4CreateSyndicationText

8CreateSyndicationTextEx

$get_SourceUri

$put_SourceUri

<CreateSyndicationContent

TCreateSyndicationContentWithSourceUri

 get_Length

 put_Length

$get_MediaType

$put_MediaType

,get_Relationship

,put_Relationship

get_Title

put_Title

4get_ResourceLanguage

4put_ResourceLanguage

4CreateSyndicationLink

8CreateSyndicationLinkEx

get_Email

put_Email

8CreateSyndicationPerson

<CreateSyndicationPersonEx

get_Label

put_Label

 get_Scheme

 put_Scheme

get_Term

put_Term

<CreateSyndicationCategory

@CreateSyndicationCategoryEx

 get_Authors

(get_Categories

,get_Contributors

 get_Content

 put_Content

get_Id

put_Id

0get_LastUpdatedTime

0put_LastUpdatedTime

get_Links

,get_PublishedDate

,put_PublishedDate

 get_Rights

 put_Rights

 get_Source

 put_Source

 get_Summary

 put_Summary

(get_CommentsUri

(put_CommentsUri

 get_EditUri

,get_EditMediaUri

get_ETag

 get_FeedUri

 get_ItemUri

Load

 LoadFromXml

4CreateSyndicationItem

$get_Generator

$put_Generator

 get_IconUri

 put_IconUri

get_Items

$get_ImageUri

$put_ImageUri

$get_Subtitle

$put_Subtitle

$get_FirstUri

 get_LastUri

 get_NextUri

(get_PreviousUri

,get_SourceFormat

4CreateSyndicationFeed

$put_Progress

$get_Progress

$put_Completed

$get_Completed

 GetResults

4get_ServerCredential

4put_ServerCredential

0get_ProxyCredential

0put_ProxyCredential

<get_MaxResponseBufferSize

<put_MaxResponseBufferSize

 get_Timeout

 put_Timeout

<get_BypassCacheOnRetrieve

<put_BypassCacheOnRetrieve

,SetRequestHeader

,RetrieveFeedAsync

8CreateSyndicationClient

$get_ValueType

Parse

Stringify

GetString

GetNumber

 GetBoolean

GetArray

GetObject

0CreateBooleanValue

,CreateNumberValue

,CreateStringValue

$GetNamedValue

$SetNamedValue

(GetNamedObject

$GetNamedArray

(GetNamedString

(GetNamedNumber

(GetNamedBoolean

,CreateJsonObject

 GetObjectAt

 GetArrayAt

 GetStringAt

 GetNumberAt

$GetBooleanAt

(CreateJsonArray

 get_Accepts

(get_Collections

(get_Workspaces

DRetrieveServiceDocumentAsync

@RetrieveMediaResourceAsync

4RetrieveResourceAsync

0CreateResourceAsync

<CreateMediaResourceAsync

<UpdateMediaResourceAsync

0UpdateResourceAsync

8UpdateResourceItemAsync

0DeleteResourceAsync

8DeleteResourceItemAsync

4CancelAsyncOperations

PCreateAtomPubClientWithCredentials

First

GetAt

get_Size

GetView

IndexOf

SetAt

InsertAt

Insert

RemoveAt

Remove

Append

 RemoveAtEnd

Clear

Lookup

HasKey

TryParse

8GetNamedValueOrDefault

8GetNamedObjectOrDefault

8GetNamedArrayOrDefault

8GetNamedStringOrDefault

8GetNamedNumberOrDefault

<GetNamedBooleanOrDefault

(CreateNullValue

DUpdateMediaResourceOperation

�4VS_VERSION_INFO��
|O
|O?�StringFileInfo�040904B0LCompanyNameMicrosoft CorporationFFileDescriptionWeb Client DLLh$FileVersion10.0.20348.1 (WinBuild.160101.0800)>InternalNameWeb Client DLL�.LegalCopyright� Microsoft Corporation. All rights reserved.POriginalFilenameWindows.Web.dll.MUIj%ProductNameMicrosoft� Windows� Operating System>
ProductVersion10.0.20348.1DVarFileInfo$Translation	�<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:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:atom03="http://purl.org/atom/ns#" xmlns:msfeednorm="urn:microsoft:feed-normalization" exclude-result-prefixes="sy atom03 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="/atom03:feed">
    <rss version="2.0">
      <channel>

        <xsl:call-template name="_OutputXmlBase"><xsl:with-param name="value" select="@xml:base"/></xsl:call-template>
        <xsl:call-template name="_OutputXmlLang"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>
        <xsl:call-template name="_OutputLanguage"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>

        <!-- Figure out the base URL value; xml:base overrides the download URL -->
        <xsl:variable name="baseChannelUrl">
          <xsl:call-template name="_GetFeedBaseUrl">
            <xsl:with-param name="downloadUrl" select="$downloadUrl"/>
            <xsl:with-param name="rootNode" select="."/>
          </xsl:call-template>
        </xsl:variable>

        <!-- Try to find the main link - one that has an href pointing to html and with type alternate -->
        <xsl:variable name="mainLink" select="atom03:link[(@rel = 'alternate' or @rel = '' or not(@rel)) and (@type = 'text/html' or @type = '' or not(@type))]"/>

        <!-- Output link -->
        <xsl:if test="$mainLink">
          <!-- Combine base URL with the main link -->
          <xsl:variable name="channelLinkUrl">
            <xsl:call-template name="_CompleteUrlTwoBase">
              <xsl:with-param name="baseUrl1" select="$baseChannelUrl"/>
              <xsl:with-param name="baseUrl2" select="$mainLink/@xml:base"/>
              <xsl:with-param name="Url" select="$mainLink/@href"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:call-template name="_OutputLink"><xsl:with-param name="value" select="$channelLinkUrl"/></xsl:call-template>
        </xsl:if>

        <!-- 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="."/></xsl:call-template>
        </xsl:variable>

        <!-- Process channel elements -->
        <xsl:apply-templates select="*" mode="channel">
          <xsl:with-param name="baseChannelUrl" select="$baseChannelUrl"/>
        </xsl:apply-templates>

        <!-- Process items -->
        <xsl:apply-templates select="atom03:entry">
          <xsl:with-param name="baseChannelUrl" select="$baseChannelUrl"/>
          <xsl:with-param name="references" select="$cfReferences"/>
        </xsl:apply-templates>

      </channel>
    </rss>
  </xsl:template>

<!-- Channel processing -->
  <xsl:template match="*" mode="channel">
    <xsl:param name="baseChannelUrl"/>
    <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(.) = $_NSatom03 and local-name(.) = 'title' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTitle">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'author'">
        <!-- First one gets converted to managing Editor -->
        <xsl:if test="$isFirst = 'true'">
          <xsl:variable name="manEditor">
            <xsl:call-template name="_ConvertAtomAuthorToAuthor">
              <xsl:with-param name="name" select="atom03:name"/>
              <xsl:with-param name="email" select="atom03:email"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:call-template name="_OutputManagingEditor"><xsl:with-param name="value" select="$manEditor"/></xsl:call-template>
        </xsl:if>
        <!-- Map to Atom 1.0 -->
        <xsl:call-template name="_OutputAtomAuthor">
          <xsl:with-param name="name" select="atom03:name"/>
          <xsl:with-param name="email" select="atom03:email"/>
          <xsl:with-param name="uri" select="atom03:url"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'contributor'">
        <!-- Map to Atom 1.0 -->
        <xsl:call-template name="_OutputAtomContributor">
          <xsl:with-param name="name" select="atom03:name"/>
          <xsl:with-param name="email" select="atom03:email"/>
          <xsl:with-param name="uri" select="atom03:url"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'tagline' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTextDescription">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'id' and $isFirst = 'true'">
        <xsl:call-template name="_OutputGuid">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="isPermaLink" select="'false'"/>
          <xsl:with-param name="channelGuid" select="'true'"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'generator' and $isFirst = 'true'">
        <xsl:call-template name="_OutputGenerator">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="uri" select="@url"/>
          <xsl:with-param name="version" select="@version"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'modified' and $isFirst = 'true'">
        <xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="."/></xsl:call-template>
        <xsl:variable name="updatedExists">
          <xsl:choose>
            <xsl:when test="../atom:updated">true</xsl:when>
            <xsl:otherwise>false</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:if test="$updatedExists = 'false'">
          <xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="."/></xsl:call-template>
        </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(../atom03:modified)">
            <xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="."/></xsl:call-template>
          </xsl:if>
        </xsl:if>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'copyright' and $isFirst = 'true'">
        <xsl:call-template name="_OutputCopyright">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </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>
      <!-- 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:call-template name="_OutputExtension"><xsl:with-param name="value" select="."/></xsl:call-template>
        </xsl:if>
      </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>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'entry'">
        <!-- Do nothing here for items -->
      </xsl:when>
      <!-- Copy extension nodes -->
      <xsl:when test="namespace-uri(.) != $_NSatom03 and namespace-uri(.) != ''">
        <xsl:call-template name="_OutputExtension"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

<!-- Item processing -->
  <xsl:template match="atom03:entry">
    <xsl:param name="baseChannelUrl"/>
    <xsl:param name="references"/>
    <item>

      <xsl:call-template name="_OutputXmlBase"><xsl:with-param name="value" select="@xml:base"/></xsl:call-template>

      <xsl:call-template name="_OutputXmlLang"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>

      <!-- Item's base URL stacks onto channel's base URL -->
      <xsl:variable name="baseChannelItemUrl">
        <xsl:call-template name="_CombineUrls">
          <xsl:with-param name="baseUrl" select="$baseChannelUrl"/>
          <xsl:with-param name="relUrl" select="@xml:base"/>
        </xsl:call-template>
      </xsl:variable>

      <!-- Try to find the main link - one that has an href pointing to html and with type alternate -->
      <xsl:variable name="mainLink" select="atom03:link[(@rel = 'alternate' or @rel = '' or not(@rel)) and (@type = 'text/html' or @type = '' or not(@type))]"/>

      <!-- Output link -->
      <xsl:if test="$mainLink">
        <!-- Combine base URL with the main link -->
        <xsl:variable name="itemLinkUrl">
          <xsl:call-template name="_CompleteUrlTwoBase">
            <xsl:with-param name="baseUrl1" select="$baseChannelItemUrl"/>
            <xsl:with-param name="baseUrl2" select="$mainLink/@xml:base"/>
            <xsl:with-param name="Url" select="$mainLink/@href"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputLink"><xsl:with-param name="value" select="$itemLinkUrl"/></xsl:call-template>
      </xsl:if>

      <xsl:apply-templates select="*" mode="item">
        <xsl:with-param name="baseItemUrl" select="$baseChannelItemUrl"/>
        <xsl:with-param name="references" select="$references"/>
      </xsl:apply-templates>

    </item>
  </xsl:template>

  <xsl:template match="*" mode="item">
    <xsl:param name="baseItemUrl"/>
    <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(.) = $_NSatom03 and local-name(.) = 'title' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTitle">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'link' and @rel = 'enclosure' and (@href or @length or @type)">
        <xsl:variable name="enclosureUrl">
          <xsl:call-template name="_CompleteUrlTwoBase">
            <xsl:with-param name="baseUrl1" select="$baseItemUrl"/>
            <xsl:with-param name="baseUrl2" select="@xml:base"/>
            <xsl:with-param name="Url" select="@href"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputEnclosure">
          <xsl:with-param name="url" select="$enclosureUrl"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'author'">
        <xsl:variable name="author">
          <xsl:call-template name="_ConvertAtomAuthorToAuthor">
            <xsl:with-param name="name" select="atom03:name"/>
            <xsl:with-param name="email" select="atom03:email"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputAuthor"><xsl:with-param name="value" select="$author"/></xsl:call-template>
        <!-- Map to Atom 1.0 -->
        <xsl:call-template name="_OutputAtomAuthor">
          <xsl:with-param name="name" select="atom03:name"/>
          <xsl:with-param name="email" select="atom03:email"/>
          <xsl:with-param name="uri" select="atom03:url"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'contributor'">
        <!-- Map to Atom 1.0 -->
        <xsl:call-template name="_OutputAtomContributor">
          <xsl:with-param name="name" select="atom03:name"/>
          <xsl:with-param name="email" select="atom03:email"/>
          <xsl:with-param name="uri" select="atom03:url"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'id' and $isFirst = 'true'">
        <xsl:call-template name="_OutputGuid">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="isPermaLink" select="'false'"/>
        </xsl:call-template>
      </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(../atom03:issued)">
            <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(.) = $_NSatom03 and local-name(.) = 'modified' and $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:when>
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'issued' and $isFirst = 'true'">
        <xsl:call-template name="_OutputPubDate"><xsl:with-param name="value" select="."/></xsl:call-template>
        <xsl:if test="not(../atom:updated) and not(../atom03:modified)">
          <xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="."/></xsl:call-template>
        </xsl:if>
        <xsl:if test="not(../atom:published)">
          <xsl:call-template name="_OutputAtomPublished"><xsl:with-param name="value" select="."/></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>
      <!-- Handle content: printable goes into description; non-printable is preserved -->
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'content' and $isFirst = 'true'">
          <xsl:if test="@type = '' or not(@type) or @type = 'text/plain' or @type = 'text/html' or @type = 'application/xhtml+xml'">
            <xsl:variable name="baseContentUrl">
              <xsl:call-template name="_CombineUrls">
                <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
                <xsl:with-param name="relUrl" select="@xml:base"/>
              </xsl:call-template>
            </xsl:variable>
            <xsl:call-template name="_OutputDescription">
              <xsl:with-param name="value" select="."/>
              <xsl:with-param name="type" select="@type"/>
              <xsl:with-param name="baseUrl" select="$baseContentUrl"/>
            </xsl:call-template>
          </xsl:if>
      </xsl:when>
      <!-- Handle summary: printable goes into description or atom:summary; non-printable is discarded -->
      <xsl:when test="namespace-uri(.) = $_NSatom03 and local-name(.) = 'summary' and $isFirst = 'true'">
        <xsl:if test="@type = '' or not(@type) or @type = 'text/plain' or @type = 'text/html' or @type = 'application/xhtml+xml'">
          <xsl:variable name="baseContentUrl">
            <xsl:call-template name="_CombineUrls">
              <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
              <xsl:with-param name="relUrl" select="@xml:base"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="not(../atom03:content[@type = '' or not(@type) or @type = 'text/plain' or @type = 'text/html' or @type = 'application/xhtml+xml'])">
              <xsl:call-template name="_OutputDescription">
                <xsl:with-param name="value" select="."/>
                <xsl:with-param name="type" select="@type"/>
                <xsl:with-param name="baseUrl" select="$baseContentUrl"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <!-- Map to Atom 1.0 -->
              <xsl:call-template name="_OutputAtomSummary">
                <xsl:with-param name="value" select="."/>
                <xsl:with-param name="type" select="@type"/>
                <xsl:with-param name="xmlBase" select="@xml:base"/>
                <xsl:with-param name="baseUrl" select="$baseContentUrl"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </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="_CompleteUrlTwoBase">
              <xsl:with-param name="baseUrl1" select="$baseItemUrl"/>
              <xsl:with-param name="baseUrl2" select="@xml:base"/>
              <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>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'link'">
        <!-- Special handling for item level atom:link with rel=entry-content: complete relative URL -->
        <xsl:variable name="atomLinkUrl">
          <xsl:choose>
            <xsl:when test="@rel = 'entry-content'">
              <xsl:call-template name="_CombineUrls">
                <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
                <xsl:with-param name="relUrl" select="@href"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@href"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="_OutputAtomLink">
          <xsl:with-param name="href" select="$atomLinkUrl"/>
          <xsl:with-param name="rel" select="@rel"/>
          <xsl:with-param name="type" select="@type"/>
          <xsl:with-param name="title" select="@title"/>
          <xsl:with-param name="hreflang" select="@hreflang"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="xmlBase" select="@xml:base"/>
        </xsl:call-template>
      </xsl:when>
      <!-- Copy extension nodes -->
      <xsl:when test="namespace-uri(.) != $_NSatom03 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:stylesheet>
PAD<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:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:msfeednorm="urn:microsoft:feed-normalization" exclude-result-prefixes="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="/atom:feed">
    <rss version="2.0">
      <channel>

        <xsl:call-template name="_OutputXmlBase"><xsl:with-param name="value" select="@xml:base"/></xsl:call-template>
        <xsl:call-template name="_OutputXmlLang"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>
        <xsl:call-template name="_OutputLanguage"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>

        <!-- Figure out the base URL value; xml:base overrides the download URL -->
        <xsl:variable name="baseChannelUrl">
          <xsl:call-template name="_GetFeedBaseUrl">
            <xsl:with-param name="downloadUrl" select="$downloadUrl"/>
            <xsl:with-param name="rootNode" select="."/>
          </xsl:call-template>
        </xsl:variable>

        <!-- Try to find the main link - one that has an href pointing to html and with type alternate -->
        <xsl:variable name="mainLink" select="atom:link[(@rel = 'alternate' or @rel = '' or not(@rel)) and (@type = 'text/html' or @type = '' or not(@type))]"/>

        <!-- Combine base URL with the main link -->
        <xsl:variable name="channelLinkUrl">
          <xsl:call-template name="_CompleteUrlTwoBase">
            <xsl:with-param name="baseUrl1" select="$baseChannelUrl"/>
            <xsl:with-param name="baseUrl2" select="$mainLink/@xml:base"/>
            <xsl:with-param name="Url" select="$mainLink/@href"/>
          </xsl:call-template>
        </xsl:variable>

        <xsl:if test="$mainLink">
          <xsl:call-template name="_OutputLink"><xsl:with-param name="value" select="$channelLinkUrl"/></xsl:call-template>
        </xsl:if>

        <xsl:if test="atom:logo">
          <xsl:variable name="logoImageUrl">
            <xsl:call-template name="_CompleteUrlTwoBase">
              <xsl:with-param name="baseUrl1" select="$baseChannelUrl"/>
              <xsl:with-param name="baseUrl2" select="atom:logo/@xml:base"/>
              <xsl:with-param name="Url" select="atom:logo"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:call-template name="_OutputImage">
            <xsl:with-param name="url" select="$logoImageUrl"/>
            <xsl:with-param name="title" select="atom:title"/>
            <xsl:with-param name="titleType" select="atom:title/@type"/>
            <xsl:with-param name="link" select="$channelLinkUrl"/>
          </xsl:call-template>
        </xsl:if>

        <!-- 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="."/></xsl:call-template>
        </xsl:variable>

        <xsl:apply-templates select="*" mode="channel">
          <xsl:with-param name="baseChannelUrl" select="$baseChannelUrl"/>
        </xsl:apply-templates>

        <xsl:apply-templates select="atom:entry">
          <xsl:with-param name="baseChannelUrl" select="$baseChannelUrl"/>
          <xsl:with-param name="references" select="$cfReferences"/>
        </xsl:apply-templates>

      </channel>
    </rss>
  </xsl:template>

<!-- Channel processing -->
  <xsl:template match="*" mode="channel">
    <xsl:param name="baseChannelUrl"/>
    <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(.) = $_NSatom1 and local-name(.) = 'updated'">
        <xsl:if test="$isFirst = 'true'">
          <xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="."/><xsl:with-param name="type" select="@type"/></xsl:call-template>
          <xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="."/><xsl:with-param name="type" select="@type"/></xsl:call-template>
        </xsl:if>
        
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'title' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTitle">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'author'">
        <!-- First one gets converted to managing Editor -->
        <xsl:if test="$isFirst = 'true'">
          <xsl:variable name="manEditor">
            <xsl:call-template name="_ConvertAtomAuthorToAuthor">
              <xsl:with-param name="name" select="atom:name"/>
              <xsl:with-param name="email" select="atom:email"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:call-template name="_OutputManagingEditor"><xsl:with-param name="value" select="$manEditor"/></xsl:call-template>
        </xsl:if>
        <!-- We also make a full copy of every atom:author -->
        <xsl:call-template name="_OutputAtomAuthor">
          <xsl:with-param name="name" select="atom:name"/>
          <xsl:with-param name="email" select="atom:email"/>
          <xsl:with-param name="uri" select="atom:uri"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'contributor'">
        <xsl:call-template name="_OutputAtomContributor">
          <xsl:with-param name="name" select="atom:name"/>
          <xsl:with-param name="email" select="atom:email"/>
          <xsl:with-param name="uri" select="atom:uri"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'subtitle' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTextDescription">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'id' and $isFirst = 'true'">
        <xsl:call-template name="_OutputGuid">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="isPermaLink" select="'false'"/>
          <xsl:with-param name="channelGuid" select="'true'"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'generator' and $isFirst = 'true'">
        <xsl:call-template name="_OutputGenerator">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="uri" select="@uri"/>
          <xsl:with-param name="version" select="@version"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'rights' and $isFirst = 'true'">
        <xsl:call-template name="_OutputCopyright">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'link'">
        <xsl:call-template name="_OutputAtomLink">
          <xsl:with-param name="href" select="@href"/>
          <xsl:with-param name="rel" select="@rel"/>
          <xsl:with-param name="type" select="@type"/>
          <xsl:with-param name="title" select="@title"/>
          <xsl:with-param name="hreflang" select="@hreflang"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="xmlBase" select="@xml:base"/>
        </xsl:call-template>
      </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>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'entry'">
        <!-- Do nothing here for items -->
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSmon and local-name(.) = 'expiration'">
        <xsl:if test="$isFirst = 'true'">
          <xsl:call-template name="_OutputMonExpiration"><xsl:with-param name="value" select="."/><xsl:with-param name="type" select="@type"/></xsl:call-template>
        </xsl:if>
      </xsl:when>
      <!-- Copy extension nodes -->
      <xsl:when test="namespace-uri(.) != $_NSatom1 and namespace-uri(.) != ''">
        <xsl:call-template name="_OutputExtension"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

<!-- Item processing -->
  <xsl:template match="atom:entry">
    <xsl:param name="baseChannelUrl"/>
    <xsl:param name="references"/>
    <item>

      <xsl:call-template name="_OutputXmlBase"><xsl:with-param name="value" select="@xml:base"/></xsl:call-template>

      <xsl:call-template name="_OutputXmlLang"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>

      <!-- Item's base URL stacks onto channel's base URL -->
      <xsl:variable name="baseChannelItemUrl">
        <xsl:call-template name="_CombineUrls">
          <xsl:with-param name="baseUrl" select="$baseChannelUrl"/>
          <xsl:with-param name="relUrl" select="@xml:base"/>
        </xsl:call-template>
      </xsl:variable>

      <!-- Try to find the main link - one that has an href pointing to html and with type alternate -->
      <xsl:variable name="mainLink" select="atom:link[(@rel = 'alternate' or @rel = '' or not(@rel)) and (@type = 'text/html' or @type = '' or not(@type))]"/>

      <!-- Output link -->
      <xsl:if test="$mainLink">
        <!-- Combine base URL with the main link -->
        <xsl:variable name="itemLinkUrl">
          <xsl:call-template name="_CompleteUrlTwoBase">
            <xsl:with-param name="baseUrl1" select="$baseChannelItemUrl"/>
            <xsl:with-param name="baseUrl2" select="$mainLink/@xml:base"/>
            <xsl:with-param name="Url" select="$mainLink/@href"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputLink"><xsl:with-param name="value" select="$itemLinkUrl"/></xsl:call-template>
      </xsl:if>

      <xsl:apply-templates select="*" mode="item">
        <xsl:with-param name="baseItemUrl" select="$baseChannelItemUrl"/>
        <xsl:with-param name="references" select="$references"/>
      </xsl:apply-templates>

    </item>
  </xsl:template>
  
  <xsl:template match="*" mode="item">
    <xsl:param name="baseItemUrl"/>
    <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>
      <!-- Process items -->
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'title' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTitle">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'link' and @rel = 'enclosure' and (@href or @length or @type)">
        <xsl:variable name="enclosureUrl">
          <xsl:call-template name="_CompleteUrlTwoBase">
            <xsl:with-param name="baseUrl1" select="$baseItemUrl"/>
            <xsl:with-param name="baseUrl2" select="@xml:base"/>
            <xsl:with-param name="Url" select="@href"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputEnclosure">
          <xsl:with-param name="url" select="$enclosureUrl"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
        <!-- We also make a full copy of the atom:link -->
        <xsl:call-template name="_OutputAtomLink">
          <xsl:with-param name="href" select="@href"/>
          <xsl:with-param name="rel" select="@rel"/>
          <xsl:with-param name="type" select="@type"/>
          <xsl:with-param name="title" select="@title"/>
          <xsl:with-param name="hreflang" select="@hreflang"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="xmlBase" select="@xml:base"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'link'">
        <!-- Special handling for item level atom:link with rel=entry-content: complete relative URL -->
        <xsl:variable name="atomLinkUrl">
          <xsl:choose>
            <xsl:when test="@rel = 'entry-content'">
              <xsl:call-template name="_CombineUrls">
                <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
                <xsl:with-param name="relUrl" select="@href"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@href"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="_OutputAtomLink">
          <xsl:with-param name="href" select="$atomLinkUrl"/>
          <xsl:with-param name="rel" select="@rel"/>
          <xsl:with-param name="type" select="@type"/>
          <xsl:with-param name="title" select="@title"/>
          <xsl:with-param name="hreflang" select="@hreflang"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="xmlBase" select="@xml:base"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'author'">
        <xsl:variable name="author">
          <xsl:call-template name="_ConvertAtomAuthorToAuthor">
            <xsl:with-param name="name" select="atom:name"/>
            <xsl:with-param name="email" select="atom:email"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputAuthor"><xsl:with-param name="value" select="$author"/></xsl:call-template>
        <!-- We also make a full copy of the atom:author -->
        <xsl:call-template name="_OutputAtomAuthor">
          <xsl:with-param name="name" select="atom:name"/>
          <xsl:with-param name="email" select="atom:email"/>
          <xsl:with-param name="uri" select="atom:uri"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'contributor'">
        <xsl:call-template name="_OutputAtomContributor">
          <xsl:with-param name="name" select="atom:name"/>
          <xsl:with-param name="email" select="atom:email"/>
          <xsl:with-param name="uri" select="atom:uri"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'id' and $isFirst = 'true'">
        <xsl:call-template name="_OutputGuid">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="isPermaLink" select="'false'"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'updated' and $isFirst = 'true'">
        <xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'published' and $isFirst = 'true'">
        <xsl:call-template name="_OutputAtomPublished"><xsl:with-param name="value" select="."/></xsl:call-template>
        <xsl:call-template name="_OutputPubDate"><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:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'category' and (@term or @scheme)">
        <xsl:call-template name="_OutputCategory">
          <xsl:with-param name="value" select="@term"/>
          <xsl:with-param name="domain" select="@scheme"/>
        </xsl:call-template>
      </xsl:when>
      <!-- Handle content: printable goes into description; non-printable is preserved -->
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'content' and $isFirst = 'true'">
        <xsl:choose>
          <xsl:when test="(@src = '' or not(@src)) and (@type = '' or not(@type) or @type = 'text' or @type = 'html' or @type = 'xhtml')">
            <xsl:variable name="baseContentUrl">
              <xsl:call-template name="_CombineUrls">
                <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
                <xsl:with-param name="relUrl" select="@xml:base"/>
              </xsl:call-template>
            </xsl:variable>
            <xsl:call-template name="_OutputDescription">
              <xsl:with-param name="value" select="."/>
              <xsl:with-param name="type" select="@type"/>
              <xsl:with-param name="baseUrl" select="$baseContentUrl"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <!-- NOTE: We don't understand content so we just won't touch it -->
            <xsl:call-template name="_OutputExtension">
              <xsl:with-param name="value" select="."/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <!-- Handle summary: printable goes into description or atom:summary; non-printable is discarded -->
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'summary' and $isFirst = 'true'">
        <xsl:if test="(@src = '' or not(@src)) and (@type = '' or not(@type) or @type = 'text' or @type = 'html' or @type = 'xhtml')">
          <xsl:variable name="baseContentUrl">
            <xsl:call-template name="_CombineUrls">
              <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
              <xsl:with-param name="relUrl" select="@xml:base"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:choose>
            <xsl:when test="not(../atom:content[(@src = '' or not(@src)) and (@type = '' or not(@type) or @type = 'text' or @type = 'html' or @type = 'xhtml')])">
              <xsl:call-template name="_OutputDescription">
                <xsl:with-param name="value" select="."/>
                <xsl:with-param name="type" select="@type"/>
                <xsl:with-param name="baseUrl" select="$baseContentUrl"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:call-template name="_OutputAtomSummary">
                <xsl:with-param name="value" select="."/>
                <xsl:with-param name="type" select="@type"/>
                <xsl:with-param name="xmlBase" select="@xml:base"/>
                <xsl:with-param name="baseUrl" select="$baseContentUrl"/>
              </xsl:call-template>
            </xsl:otherwise>
          </xsl:choose>
        </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="_CompleteUrlTwoBase">
              <xsl:with-param name="baseUrl1" select="$baseItemUrl"/>
              <xsl:with-param name="baseUrl2" select="@xml:base"/>
              <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(.) != $_NSatom1 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:stylesheet>
PA<?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>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'link'">
        <!-- Special handling for item level atom:link with rel=entry-content: complete relative URL -->
        <xsl:variable name="atomLinkUrl">
          <xsl:choose>
            <xsl:when test="@rel = 'entry-content'">
              <xsl:call-template name="_CombineUrls">
                <xsl:with-param name="baseUrl" select="$downloadUrl"/>
                <xsl:with-param name="relUrl" select="@href"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@href"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="_OutputAtomLink">
          <xsl:with-param name="href" select="$atomLinkUrl"/>
          <xsl:with-param name="rel" select="@rel"/>
          <xsl:with-param name="type" select="@type"/>
          <xsl:with-param name="title" select="@title"/>
          <xsl:with-param name="hreflang" select="@hreflang"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="xmlBase" select="@xml:base"/>
        </xsl:call-template>
      </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>
PAD<?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:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:msfeednorm="urn:microsoft:feed-normalization" exclude-result-prefixes="dcterms msfeednorm">

<!-- Shared templates -->
  <xsl:import href="res://msfeeds.dll/SharedNormalizer.xsl"/>

<!-- Output XML UTF-8 -->
  <xsl:output method="xml" encoding="utf-8"/>
  
<!-- Figure out the type for RSS 2.0 text fields -->
  <xsl:template name="_GetRSS2TypeValue">
    <xsl:param name="type"/>
    <xsl:param name="default"/>
    <xsl:choose>
      <xsl:when test="normalize-space($type) = 'html'">html</xsl:when>
      <xsl:when test="normalize-space($type) = 'text'">text</xsl:when>
      <xsl:when test="not(string($type)) or normalize-space($type) = ''"><xsl:value-of select="$default"/></xsl:when>
      <xsl:otherwise>invalid</xsl:otherwise>
      <!-- Note that unknown value for a type will yield empty output -->
    </xsl:choose>
  </xsl:template>

<!-- Entry point -->
  <xsl:template match="/rss">
    <rss>
      <!-- Copy all namespaces -->
      <xsl:for-each select="namespace::*"><xsl:copy/></xsl:for-each>

      <!-- Ensure version is 2.0 -->
      <xsl:attribute name="version">2.0</xsl:attribute>

      <!-- Process channel -->
      <channel>
        <xsl:apply-templates select="channel"/>
      </channel>
    </rss>
  </xsl:template>

<!-- Channel processing -->
  <xsl:template match="channel">
    <!-- Copy all namespaces -->
    <xsl:for-each select="namespace::*">
      <xsl:copy/>
    </xsl:for-each>

    <xsl:call-template name="_OutputXmlBase"><xsl:with-param name="value" select="@xml:base"/></xsl:call-template>
    <xsl:call-template name="_OutputXmlLang"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>
    <xsl:if test="not(language)">
      <xsl:call-template name="_OutputLanguage"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>
    </xsl:if>

    <!-- Figure out the base URL value; xml:base overrides the download URL -->
    <xsl:variable name="baseChannelUrl">
      <xsl:call-template name="_GetFeedBaseUrl">
        <xsl:with-param name="downloadUrl" select="$downloadUrl"/>
        <xsl:with-param name="rootNode" select="."/>
      </xsl:call-template>
    </xsl:variable>

    <!-- 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="."/></xsl:call-template>
    </xsl:variable>

    <!-- Process channel elements -->
    <xsl:apply-templates select="*" mode="channel">
      <xsl:with-param name="baseChannelUrl" select="$baseChannelUrl"/>
    </xsl:apply-templates>

    <!-- Process items -->
    <xsl:apply-templates select="item">
      <xsl:with-param name="baseChannelUrl" select="$baseChannelUrl"/>
      <xsl:with-param name="references" select="$cfReferences"/>
    </xsl:apply-templates>
  </xsl:template>

  <xsl:template match="*" mode="channel">
    <xsl:param name="baseChannelUrl"/>
    <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(.) = '' and local-name(.) = 'title' and $isFirst = 'true'">
        <xsl:variable name="type">
          <xsl:call-template name="_GetRSS2TypeValue">
            <xsl:with-param name="type" select="@cf:type"/>
            <xsl:with-param name="default" select="'text'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputTitle">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="$type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'link' and $isFirst = 'true'">
        <xsl:variable name="linkUrl">
          <xsl:call-template name="_CompleteUrl">
            <xsl:with-param name="baseUrl" select="$baseChannelUrl"/>
            <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(.) = '' and local-name(.) = 'description' and $isFirst = 'true'">
        <xsl:variable name="type">
          <xsl:call-template name="_GetRSS2TypeValue">
            <xsl:with-param name="type" select="@cf:type"/>
            <xsl:with-param name="default" select="'text'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputTextDescription">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="$type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'pubDate' and $isFirst = 'true'">
        <xsl:call-template name="_OutputPubDate"><xsl:with-param name="value" select="."/></xsl:call-template>
        <xsl:if test="not(../lastBuildDate)">
          <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(../pubDate) and not(../lastBuildDate)">
            <xsl:call-template name="_OutputLastBuildDate"><xsl:with-param name="value" select="."/></xsl:call-template>
          </xsl:if>
        </xsl:if>  
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'language' and $isFirst = 'true'">
        <xsl:call-template name="_OutputLanguage"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'copyright' and $isFirst = 'true'">
        <xsl:variable name="type">
          <xsl:call-template name="_GetRSS2TypeValue">
            <xsl:with-param name="type" select="@cf:type"/>
            <xsl:with-param name="default" select="'text'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputCopyright">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="$type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'lastBuildDate' and $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:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'managingEditor' and $isFirst = 'true'">
        <xsl:variable name="convertToAtom">
          <xsl:choose>
            <xsl:when test="../atom:author">false</xsl:when>
            <xsl:otherwise>true</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="_OutputManagingEditor">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="convertToAtom" select="$convertToAtom"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'webMaster' and $isFirst = 'true'">
        <xsl:call-template name="_OutputWebMaster"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'category'">
        <xsl:call-template name="_OutputCategory">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="domain" select="@domain"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'generator' and $isFirst = 'true'">
        <xsl:call-template name="_OutputGenerator">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="uri" select="@cf:uri"/>
          <xsl:with-param name="version" select="@cf:version"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'docs' and $isFirst = 'true'">
        <xsl:call-template name="_OutputDocs"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'cloud' and $isFirst = 'true'">
        <xsl:call-template name="_OutputCloud"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'ttl' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTtl"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'image' and $isFirst = 'true'">
        <xsl:variable name="imageUrl">
          <xsl:call-template name="_CompleteUrl">
            <xsl:with-param name="baseUrl" select="$baseChannelUrl"/>
            <xsl:with-param name="Url" select="url"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:variable name="imageLink">
          <xsl:call-template name="_CompleteUrl">
            <xsl:with-param name="baseUrl" select="$baseChannelUrl"/>
            <xsl:with-param name="Url" select="link"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputImage">
          <xsl:with-param name="url" select="$imageUrl"/>
          <xsl:with-param name="title" select="title"/>
          <xsl:with-param name="link" select="$imageLink"/>
          <xsl:with-param name="width" select="width"/>
          <xsl:with-param name="height" select="height"/>
          <xsl:with-param name="description" select="description"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'rating' and $isFirst = 'true'">
        <xsl:call-template name="_OutputRating"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'textInput' and $isFirst = 'true'">
        <xsl:call-template name="_OutputTextInput">
          <xsl:with-param name="title" select="title"/>
          <xsl:with-param name="name" select="name"/>
          <xsl:with-param name="link" select="link"/>
          <xsl:with-param name="description" select="description"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'skipHours' and $isFirst = 'true'">
        <xsl:call-template name="_OutputSkipHours"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'skipDays' and $isFirst = 'true'">
        <xsl:call-template name="_OutputSkipDays"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'link'">
        <xsl:call-template name="_OutputAtomLink">
          <xsl:with-param name="href" select="@href"/>
          <xsl:with-param name="rel" select="@rel"/>
          <xsl:with-param name="type" select="@type"/>
          <xsl:with-param name="title" select="@title"/>
          <xsl:with-param name="hreflang" select="@hreflang"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="xmlBase" select="@xml:base"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'author'">
        <xsl:if test="$isFirst = 'true'">
          <xsl:call-template name="_OutputAtomAuthor">
            <xsl:with-param name="name" select="atom:name"/>
            <xsl:with-param name="email" select="atom:email"/>
            <xsl:with-param name="uri" select="atom:uri"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'contributor'">
          <xsl:call-template name="_OutputAtomContributor">
            <xsl:with-param name="name" select="atom:name"/>
            <xsl:with-param name="email" select="atom:email"/>
            <xsl:with-param name="uri" select="atom:uri"/>
          </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>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'item'">
        <!-- Do nothing here for items -->
      </xsl:when>
      <!-- Copy extension nodes -->
      <xsl:when test="namespace-uri(.) != ''">
        <xsl:call-template name="_OutputExtension"><xsl:with-param name="value" select="."/></xsl:call-template>
      </xsl:when>
    </xsl:choose>
  </xsl:template>

<!-- Item processing -->
  <xsl:template match="item">
    <xsl:param name="baseChannelUrl"/>
    <xsl:param name="references"/>
    <item>
      <!-- Copy all namespaces -->
      <xsl:for-each select="namespace::*">
        <xsl:copy/>
      </xsl:for-each>

      <xsl:call-template name="_OutputXmlBase"><xsl:with-param name="value" select="@xml:base"/></xsl:call-template>
      <xsl:call-template name="_OutputXmlLang"><xsl:with-param name="value" select="@xml:lang"/></xsl:call-template>

      <!-- Item's base URL stacks onto channel's base URL -->
      <xsl:variable name="baseChannelItemUrl">
        <xsl:call-template name="_CombineUrls">
          <xsl:with-param name="baseUrl" select="$baseChannelUrl"/>
          <xsl:with-param name="relUrl" select="@xml:base"/>
        </xsl:call-template>
      </xsl:variable>

      <!-- Process item elements -->
      <xsl:apply-templates select="*" mode="item">
        <xsl:with-param name="baseItemUrl" select="$baseChannelItemUrl"/>
        <xsl:with-param name="references" select="$references"/>
      </xsl:apply-templates>
    </item>
  </xsl:template>

  <xsl:template match="*" mode="item">
    <xsl:param name="baseItemUrl"/>
    <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(.) = '' and local-name(.) = 'title' and $isFirst = 'true'">
        <xsl:variable name="type">
          <xsl:call-template name="_GetRSS2TypeValue">
            <xsl:with-param name="type" select="@cf:type"/>
            <xsl:with-param name="default" select="'text'"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputTitle">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="type" select="$type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'link' and $isFirst = 'true'">
        <xsl:variable name="linkUrl">
          <xsl:call-template name="_CompleteUrl">
            <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
            <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(.) = '' and local-name(.) = 'author') or (namespace-uri(.) = $_NSdc and local-name(.) = 'creator')">
        <xsl:variable name="convertToAtom">
          <xsl:choose>
            <xsl:when test="../atom:author">false</xsl:when>
            <xsl:otherwise>true</xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="_OutputAuthor">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="convertToAtom" select="$convertToAtom"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'contributor'">
        <xsl:call-template name="_OutputAtomContributor">
          <xsl:with-param name="name" select="atom:name"/>
          <xsl:with-param name="email" select="atom:email"/>
          <xsl:with-param name="uri" select="atom:uri"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'category'">
        <xsl:call-template name="_OutputCategory">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="domain" select="@domain"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'comments' and $isFirst = 'true'">
        <xsl:variable name="commentUrl">
          <xsl:call-template name="_CompleteUrl">
            <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
            <xsl:with-param name="Url" select="."/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputComments"><xsl:with-param name="value" select="$commentUrl"/></xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'enclosure'">
        <xsl:variable name="enclosureUrl">
          <xsl:call-template name="_CompleteUrl">
            <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
            <xsl:with-param name="Url" select="@url"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputEnclosure">
          <xsl:with-param name="url" select="$enclosureUrl"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="type" select="@type"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'guid' and $isFirst = 'true'">
        <xsl:choose>
          <xsl:when test="normalize-space(@isPermaLink) = 'true' or not(string(@isPermaLink))">
            <xsl:variable name="linkUrl">
              <xsl:call-template name="_CompleteUrl">
                <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
                <xsl:with-param name="Url" select="."/>
              </xsl:call-template>
            </xsl:variable>
            <xsl:call-template name="_OutputGuid">
              <xsl:with-param name="value" select="$linkUrl"/>
              <xsl:with-param name="isPermaLink" select="@isPermaLink"/>
            </xsl:call-template>
            <!-- If there is no link we'll use permalink guid instead -->
            <xsl:if test="not(../link)">
              <xsl:call-template name="_OutputLink"><xsl:with-param name="value" select="$linkUrl"/></xsl:call-template>
            </xsl:if>
          </xsl:when>
          <xsl:otherwise>
            <xsl:call-template name="_OutputGuid">
              <xsl:with-param name="value" select="."/>
              <xsl:with-param name="isPermaLink" select="@isPermaLink"/>
            </xsl:call-template>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'pubDate' and $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:when>
      <xsl:when test="namespace-uri(.) = $_NSdc and local-name(.) = 'date'">
        <xsl:if test="$isFirst = 'true' and not(../pubDate) and not(../dcterms:modified) and not(../atom:updated)">
          <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' and not(../atom:updated)">
          <xsl:call-template name="_OutputAtomUpdated"><xsl:with-param name="value" select="."/></xsl:call-template>
        </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(.) = $_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(../pubDate)">
            <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(.) = '' and local-name(.) = 'source' and $isFirst = 'true'">
        <xsl:variable name="srcUrl">
          <xsl:call-template name="_CompleteUrl">
            <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
            <xsl:with-param name="Url" select="@url"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:call-template name="_OutputSource">
          <xsl:with-param name="value" select="."/>
          <xsl:with-param name="url" select="$srcUrl"/>
        </xsl:call-template>
      </xsl:when>
      <!-- content:encoded takes precedence over the description -->
      <xsl:when test="namespace-uri(.) = $_NScontent and local-name(.) = 'encoded'">
        <xsl:if test="$isFirst = 'true'">
          <xsl:variable name="summType">
            <xsl:call-template name="_GetRSS2TypeValue">
              <xsl:with-param name="type" select="../description/@cf:type"/>
              <xsl:with-param name="default" select="'html'"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:variable name="baseDescUrl">
            <xsl:call-template name="_CombineUrls">
              <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
              <xsl:with-param name="relUrl" select="@xml:base"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:variable name="baseSummUrl">
            <xsl:call-template name="_CombineUrls">
              <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
              <xsl:with-param name="relUrl" select="../description/@xml:base"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:call-template name="_OutputDescriptionAndSummary">
            <xsl:with-param name="description" select="."/>
            <xsl:with-param name="descriptionType" select="'html'"/>
            <xsl:with-param name="descriptionBaseUrl" select="$baseDescUrl"/>
            <xsl:with-param name="summary" select="../description"/>
            <xsl:with-param name="summaryType" select="$summType"/>
            <xsl:with-param name="summaryXmlBase" select="../description/@xml:base"/>
            <xsl:with-param name="summaryBaseUrl" select="$baseSummUrl"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:when>
      <!-- description will be used if there is no content:encoded -->
      <xsl:when test="namespace-uri(.) = '' and local-name(.) = 'description' and $isFirst = 'true'">
        <xsl:if test="not(../*[namespace-uri(.) = $_NScontent and local-name(.) = 'encoded'])">
          <xsl:variable name="type">
            <xsl:call-template name="_GetRSS2TypeValue">
              <xsl:with-param name="type" select="@cf:type"/>
              <xsl:with-param name="default" select="'html'"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:variable name="baseDescUrl">
            <xsl:call-template name="_CombineUrls">
              <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
              <xsl:with-param name="relUrl" select="@xml:base"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:call-template name="_OutputDescription">
            <xsl:with-param name="value" select="."/>
            <xsl:with-param name="type" select="$type"/>
            <xsl:with-param name="baseUrl" select="$baseDescUrl"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:when>
      <!-- atom:summary will be preserved unless both content:encoded and description are present -->
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'summary'">
        <xsl:if test="$isFirst = 'true' and not(../description and ../*[namespace-uri(.) = $_NScontent and local-name(.) = 'encoded'])">
          <xsl:variable name="baseSummUrl">
            <xsl:call-template name="_CombineUrls">
              <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
              <xsl:with-param name="relUrl" select="@xml:base"/>
            </xsl:call-template>
          </xsl:variable>
          <xsl:call-template name="_OutputAtomSummary">
            <xsl:with-param name="value" select="."/>
            <xsl:with-param name="type" select="@type"/>
            <xsl:with-param name="xmlBase" select="@xml:base"/>
            <xsl:with-param name="baseUrl" select="$baseSummUrl"/>
          </xsl:call-template>
        </xsl:if>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'link'">
        <!-- Special handling for item level atom:link with rel=entry-content: complete relative URL -->
        <xsl:variable name="atomLinkUrl">
          <xsl:choose>
            <xsl:when test="@rel = 'entry-content'">
              <xsl:call-template name="_CombineUrls">
                <xsl:with-param name="baseUrl" select="$baseItemUrl"/>
                <xsl:with-param name="relUrl" select="@href"/>
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="@href"/>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="_OutputAtomLink">
          <xsl:with-param name="href" select="$atomLinkUrl"/>
          <xsl:with-param name="rel" select="@rel"/>
          <xsl:with-param name="type" select="@type"/>
          <xsl:with-param name="title" select="@title"/>
          <xsl:with-param name="hreflang" select="@hreflang"/>
          <xsl:with-param name="length" select="@length"/>
          <xsl:with-param name="xmlBase" select="@xml:base"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="namespace-uri(.) = $_NSatom1 and local-name(.) = 'author'">
        <xsl:call-template name="_OutputAtomAuthor">
          <xsl:with-param name="name" select="atom:name"/>
          <xsl:with-param name="email" select="atom:email"/>
          <xsl:with-param name="uri" select="atom:uri"/>
        </xsl:call-template>
      </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="$baseItemUrl"/>
              <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(.) != ''">
        <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:stylesheet>
PAD<?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:msfeednorm="urn:microsoft:feed-normalization" exclude-result-prefixes="msfeednorm">

<!-- IMPORTANT: This shared XSL gets imported using our code by copying all the xsl:stylesheet's children, 
so all of the above namespace declarations must be present in each other XSL where this is imported into. -->

<!-- Download URL is inserted from the normalization code -->
  <xsl:param name="downloadUrl"/>

<!-- 
Namespaces commonly used in RSS feeds 
-->

<xsl:variable name="_NSatom1" select="'http://www.w3.org/2005/Atom'"/>
<xsl:variable name="_NSatom03" select="'http://purl.org/atom/ns#'"/>
<xsl:variable name="_NSsy" select="'http://purl.org/rss/1.0/modules/syndication/'"/>
<xsl:variable name="_NScontent" select="'http://purl.org/rss/1.0/modules/content/'"/>
<xsl:variable name="_NSrdf" select="'http://www.w3.org/1999/02/22-rdf-syntax-ns#'"/>
<xsl:variable name="_NSrss" select="'http://purl.org/rss/1.0/'"/>
<xsl:variable name="_NSdc" select="'http://purl.org/dc/elements/1.1/'"/>
<xsl:variable name="_NSdcterms" select="'http://purl.org/dc/terms/'"/>
<xsl:variable name="_NSslash" select="'http://purl.org/rss/1.0/modules/slash/'"/>
<xsl:variable name="_NSwfw" select="'http://wellformedweb.org/CommentAPI/'"/>
<xsl:variable name="_NScf" select="'http://www.microsoft.com/schemas/rss/core/2005'"/>
<xsl:variable name="_NScfi" select="'http://www.microsoft.com/schemas/rss/core/2005/internal'"/>
<xsl:variable name="_NSxhtml" select="'http://www.w3.org/1999/xhtml'"/>
<xsl:variable name="_NSmon" select="'http://www.microsoft.com/schemas/rss/monitoring/2007'"/>


<!--
Conversion and utility/helper templates
-->

<!-- Find if current node is a first one of its kind; returns strings 'true' when first or 'false' when not -->
<xsl:template name="_IsFirstChildOfItsKind">
  <xsl:param name="value"/>
  <xsl:variable name="_nameSpace" select="namespace-uri($value)"/>
  <xsl:variable name="_localName" select="local-name($value)"/>
  <xsl:variable name="_currentId" select="generate-id($value)"/>
  <xsl:variable name="_firstId" select="generate-id($value/../*[namespace-uri(.) = $_nameSpace and local-name(.) = $_localName])"/>
  <xsl:choose>
    <xsl:when test="$_currentId = $_firstId">
      <xsl:value-of select="'true'"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="'false'"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- Convert updateFrequency and updatePeriod to ttl -->
  <xsl:template name="_ConvertUpdatesToTtl">
    <xsl:param name="updateFrequency"/>
    <xsl:param name="updatePeriod"/>
    <xsl:variable name="_updateFrequencyNum" select="number($updateFrequency)"/>
    <xsl:variable name="_updatePeriodTmp">
      <xsl:choose>
        <xsl:when test="$updatePeriod = 'hourly'">60</xsl:when>
        <xsl:when test="$updatePeriod = 'daily'">1440</xsl:when>
        <xsl:when test="$updatePeriod = 'weekly'">10080</xsl:when>
        <xsl:when test="$updatePeriod = 'monthly'">40320</xsl:when>
        <xsl:when test="$updatePeriod = 'yearly'">483840</xsl:when>
        <xsl:otherwise>-1</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="_updatePeriodNum" select="number($_updatePeriodTmp)"/>
    <xsl:if test="$_updateFrequencyNum &gt; 0 and $_updatePeriodNum &gt; 0">
      <ttl>
        <xsl:value-of select="$_updatePeriodNum div $_updateFrequencyNum"/>
      </ttl>
    </xsl:if>
  </xsl:template>

<!-- Convert author strings to Atom format (very simple implementation) -->
  <!-- NOTE: Assumes that value has been properly scrubbed and only needs to be parsed -->
  <xsl:template name="_ConvertAuthorToAtomAuthor">
    <xsl:param name="value"/>
    <xsl:if test="string($value)">
      <atom:author>
        <xsl:choose>
          <!-- No email -->
          <xsl:when test="contains($value, '@') = false">
            <atom:name><xsl:value-of select="$value"/></atom:name>
          </xsl:when>
          <!-- Name and email -->
          <xsl:when test="contains($value, '(') and contains($value, ')')">
            <xsl:variable name="_BeforeOpenParen" select="substring-before($value, '(')"/>
            <xsl:variable name="_AfterCloseParen" select="substring-after($value, ')')"/>
            <xsl:variable name="_WithinParens" select="substring-after(substring-before($value, ')'), '(')"/>
            <xsl:choose>
              <!-- Simple check for some possible weird cases -->
              <xsl:when test="contains($_BeforeOpenParen, ')') or contains($_AfterCloseParen, '(') or contains($_WithinParens, '(')">
                <atom:name><xsl:value-of select="$value"/></atom:name>
              </xsl:when>
              <!-- Email within parens -->
              <xsl:when test="contains($_WithinParens, '@')">
                <atom:name><xsl:value-of select="concat($_BeforeOpenParen, $_AfterCloseParen)"/></atom:name>
                <atom:email><xsl:value-of select="$_WithinParens"/></atom:email>
              </xsl:when>
              <!-- Name within parens -->
              <xsl:otherwise>
                <atom:name><xsl:value-of select="$_WithinParens"/></atom:name>
                <xsl:choose>
                  <!-- Email before parens -->
                  <xsl:when test="contains($_BeforeOpenParen, '@')">
                    <atom:email><xsl:value-of select="$_BeforeOpenParen"/></atom:email>
                  </xsl:when>
                  <!-- Email after parens -->
                  <xsl:otherwise>
                    <atom:email><xsl:value-of select="$_AfterCloseParen"/></atom:email>
                  </xsl:otherwise>
                </xsl:choose>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <!-- Only email -->
          <xsl:otherwise>
            <atom:email><xsl:value-of select="$value"/></atom:email>
          </xsl:otherwise>
        </xsl:choose>
      </atom:author>
    </xsl:if>
  </xsl:template>

<!-- Convert Atom author strings to RSS 2.0 format with email and name -->
  <xsl:template name="_ConvertAtomAuthorToAuthor">
    <xsl:param name="name"/>
    <xsl:param name="email"/>
    <xsl:choose>
      <xsl:when test="string($name) and string($email)"><xsl:value-of select="concat($email, ' (', $name, ')')"/></xsl:when>
      <xsl:when test="string($email)"><xsl:value-of select="string($email)"/></xsl:when>
      <xsl:otherwise><xsl:value-of select="string($name)"/></xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
<!-- Map type values to Atom 1.0 type -->
<!-- Note that our sanitization code can parse but cannot output XHTML, so xhtml gets converted to html -->
  <xsl:template name="_NormalizeAtomTextTypeAttr">
    <xsl:param name="value"/>
    <xsl:choose>
      <xsl:when test="not(string($value)) or normalize-space($value) = ''"><xsl:attribute name="type">text</xsl:attribute></xsl:when>
      <xsl:when test="$value = 'text/plain' or $value = 'text'"><xsl:attribute name="type">text</xsl:attribute></xsl:when>
      <xsl:when test="$value = 'text/html' or $value = 'html'"><xsl:attribute name="type">html</xsl:attribute></xsl:when>
      <xsl:when test="$value = 'application/xhtml+xml' or $value = 'xhtml'"><xsl:attribute name="type">html</xsl:attribute></xsl:when>
    </xsl:choose>
  </xsl:template>

<!-- Validate bool -->
  <xsl:template name="_ValidateBool">
    <xsl:param name="value"/>
    <xsl:choose>
      <xsl:when test="normalize-space($value) = 'true'">true</xsl:when>
      <xsl:when test="normalize-space($value) = 'false'">false</xsl:when>
    </xsl:choose>
  </xsl:template>

<!-- Build a list of nodes that are referenced from the cf:sort or cf:group -->
  <xsl:template name="_BuildCfReferenceList">
    <xsl:param name="value"/>
    <!-- We format the node references as "'namespace-uri':local-name;" -->
    <xsl:for-each select="$value/cf:listinfo/cf:sort">
      <xsl:choose>
        <xsl:when test="@element">'<xsl:value-of select="@ns"/>':<xsl:value-of select="@element"/>;</xsl:when>
        <xsl:otherwise>'<xsl:value-of select="@ns"/>':<xsl:value-of select="@label"/>;</xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
    <xsl:for-each select="$value/cf:listinfo/cf:group">
      <xsl:choose>
        <xsl:when test="@element">'<xsl:value-of select="@ns"/>':<xsl:value-of select="@element"/>;</xsl:when>
        <xsl:otherwise>'<xsl:value-of select="@ns"/>':<xsl:value-of select="@label"/>;</xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

<!-- Ensure XHTML is the default namespace; needs to run prior to sanitization; exact preserving of namespace prefixes
is not important because sanitization will drop all the unknown elements anyway -->
  <xsl:template name="_NormalizeXhtmlNamespacePrefix">
    <xsl:param name="value"/>
    <xsl:for-each select="$value">
      <xsl:choose>
        <xsl:when test="self::text() or self::comment() or self::processing-instruction()">
          <xsl:copy/>
        </xsl:when>
        <!-- xhtml is default namespace: just copy and process children -->
        <xsl:when test="namespace-uri(.) = $_NSxhtml and not(contains(name(.), ':'))">
          <xsl:copy>
            <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
            <xsl:call-template name="_NormalizeXhtmlNamespacePrefix">
              <xsl:with-param name="value" select="*|text()"/>
            </xsl:call-template>
          </xsl:copy>
        </xsl:when>
        <xsl:otherwise>
          <xsl:choose>
            <!-- xhtml element in non-default namespace: fix namespace and process children -->
            <xsl:when test="namespace-uri(.) = $_NSxhtml">
              <xsl:element name="{local-name(.)}" namespace="{$_NSxhtml}">
                <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
                <xsl:call-template name="_NormalizeXhtmlNamespacePrefix">
                  <xsl:with-param name="value" select="*|text()"/>
                </xsl:call-template>
              </xsl:element>
            </xsl:when>
            <!-- non-xhtml element in default namespace: fix namespace and process children -->
            <xsl:otherwise>
              <xsl:element name="{concat('x:', local-name(.))}" namespace="{namespace-uri(.)}">
                <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
                <xsl:call-template name="_NormalizeXhtmlNamespacePrefix">
                  <xsl:with-param name="value" select="*|text()"/>
                </xsl:call-template>
              </xsl:element>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:template>

<!-- Combine base and relative URLs -->
  <xsl:template name="_CombineUrls">
    <xsl:param name="baseUrl"/>
    <xsl:param name="relUrl"/>
    <xsl:choose>
      <xsl:when test="string($baseUrl)">
        <xsl:value-of select="msfeednorm:CombineUrls(string($baseUrl), string($relUrl))"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="string($relUrl)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

<!-- Check for URL and combine it with base (complete the URL) -->
  <xsl:template name="_CompleteUrl">
    <xsl:param name="Url"/>
    <xsl:param name="baseUrl"/>
    <xsl:if test="string($Url)">
      <xsl:value-of select="msfeednorm:CombineUrls(string($baseUrl), string($Url))"/>
    </xsl:if>
  </xsl:template>

<!-- Complete URL in order: baseUrl1 + baseUrl2 + Url -->
  <xsl:template name="_CompleteUrlTwoBase">
    <xsl:param name="Url"/>
    <xsl:param name="baseUrl1"/>
    <xsl:param name="baseUrl2"/>
    <xsl:variable name="combinedBase">
      <xsl:call-template name="_CombineUrls">
        <xsl:with-param name="baseUrl" select="$baseUrl1"/>
        <xsl:with-param name="relUrl" select="$baseUrl2"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:call-template name="_CompleteUrl">
      <xsl:with-param name="Url" select="$Url"/>
      <xsl:with-param name="baseUrl" select="$combinedBase"/>
    </xsl:call-template>
  </xsl:template>

<!-- Figure out the base URL for the feed -->
  <xsl:template name="_GetFeedBaseUrl">
    <xsl:param name="downloadUrl"/>
    <xsl:param name="rootNode"/>
    <xsl:choose>
      <xsl:when test="string($rootNode/@xml:base)">
        <xsl:call-template name="_CombineUrls">
          <xsl:with-param name="baseUrl" select="$downloadUrl"/>
          <xsl:with-param name="relUrl" select="$rootNode/@xml:base"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="string($downloadUrl)"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


<!--
Sanitization and validation templates
-->

<!-- Invoke sanitization and/or transformation based on the from and to types -->
  <xsl:template name="_CleanByType">
    <xsl:param name="value"/>
    <xsl:param name="fromType"/>
    <xsl:param name="toType"/>
    <xsl:param name="baseUrl"/>
    <xsl:variable name="fromTypeN" select="normalize-space($fromType)"/>
    <xsl:variable name="toTypeN" select="normalize-space($toType)"/>
    <xsl:choose>
      <xsl:when test="not(string($fromTypeN)) or $fromTypeN = 'text' or $fromTypeN = 'text/plain'">
        <xsl:choose>
          <!-- text->text: just copy -->
          <xsl:when test="not(string($toTypeN)) or $toTypeN = 'text' or $toTypeN = 'text/plain'">
            <xsl:value-of select="$value"/>
          </xsl:when>
          <!-- text->html: escape -->
          <xsl:when test="$toTypeN = 'html' or $toTypeN = 'text/html'">
            <xsl:value-of select="msfeednorm:HtmlEscape(string($value))"/>
          </xsl:when>
        </xsl:choose>
      </xsl:when>
      <xsl:when test="$fromTypeN = 'html' or $fromTypeN = 'text/html'">
        <xsl:choose>
          <!-- html->text: drop all html and unescape -->
          <xsl:when test="not(string($toTypeN)) or $toTypeN = 'text' or $toTypeN = 'text/plain'">
            <xsl:value-of select="msfeednorm:CleanHtmlToPlainText(string($value))"/>
          </xsl:when>
          <!-- html->html: drop unsafe html -->
          <xsl:when test="$toTypeN = 'html' or $toTypeN = 'text/html'">
            <xsl:value-of select="msfeednorm:CleanHtmlToSafeHtml(string($baseUrl), string($value))"/>
          </xsl:when>
        </xsl:choose>
      </xsl:when>
      <xsl:when test="$fromTypeN = 'xhtml' or $fromTypeN = 'application/xhtml+xml'">
        <xsl:variable name="normXhtml">
          <xsl:call-template name="_NormalizeXhtmlNamespacePrefix">
            <xsl:with-param name="value" select="$value/*"/>
          </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
          <!-- xhtml->text: drop all html and unescape -->
          <xsl:when test="not(string($toTypeN)) or $toTypeN = 'text' or $toTypeN = 'text/plain'">
            <xsl:value-of select="msfeednorm:CleanXhtmlToPlainText($normXhtml)"/>
          </xsl:when>
          <!-- xhtml->html: drop unsafe html -->
          <xsl:when test="$toTypeN = 'html' or $toTypeN = 'text/html'">
            <xsl:value-of select="msfeednorm:CleanXhtmlToSafeXhtml(string($baseUrl), $normXhtml)"/>
          </xsl:when>
        </xsl:choose>
      </xsl:when>
      <!-- Note that any unknown type value will yield empty output -->
    </xsl:choose>
  </xsl:template>


<!--
Generic output templates
-->

<!-- Output attribute with plain text value -->
  <xsl:template name="_OutputTextAttribute">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue">
      <xsl:call-template name="_CleanByType">
        <xsl:with-param name="value" select="$value"/>
        <xsl:with-param name="fromType" select="'text'"/>
        <xsl:with-param name="toType" select="'text'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:if test="string($_validatedValue)">
      <xsl:attribute name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:attribute>
    </xsl:if>
  </xsl:template>
  
<!-- Output attribute with bool value -->
  <xsl:template name="_OutputBoolAttribute">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue">
      <xsl:call-template name="_ValidateBool"><xsl:with-param name="value" select="$value"/></xsl:call-template>
    </xsl:variable>
    <xsl:if test="string($_validatedValue)">
      <xsl:attribute name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:attribute>
    </xsl:if>
  </xsl:template>

<!-- Output attribute with URL value -->
  <xsl:template name="_OutputUrlAttribute">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue" select="msfeednorm:ValidateUrl(normalize-space($value))"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:attribute name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:attribute>
    </xsl:if>
  </xsl:template>
  
  <xsl:template name="_OutputUriAttribute">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue" select="msfeednorm:NormalizeUri(normalize-space($value))"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:attribute name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:attribute>
    </xsl:if>
  </xsl:template>

<!-- Output attribute with mime-type value -->
  <xsl:template name="_OutputMimeTypeAttribute">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue" select="normalize-space($value)"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:attribute name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:attribute>
    </xsl:if>
  </xsl:template>

<!-- Output attribute with non-negative number value -->
  <xsl:template name="_OutputPositiveNumberAttribute">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue" select="number($value)"/>
    <xsl:if test="(string($_validatedValue) != 'NaN') and ($_validatedValue &gt;= 0)">
      <xsl:attribute name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:attribute>
    </xsl:if>
  </xsl:template>

<!-- Output element with plain text value -->
  <xsl:template name="_OutputTextElement">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:param name="type" select="'text'"/>
    <xsl:param name="outputTypeAttribute" select="'false'"/>
    <xsl:variable name="_validatedValue">
      <xsl:call-template name="_CleanByType">
        <xsl:with-param name="value" select="$value"/>
        <xsl:with-param name="fromType" select="$type"/>
        <xsl:with-param name="toType" select="'text'"/>
      </xsl:call-template>
    </xsl:variable>
    <xsl:if test="string($_validatedValue)">
      <xsl:element name="{$tagName}" namespace="{$nameSpace}">
        <xsl:if test="$outputTypeAttribute = 'true'">
          <xsl:attribute name="cf:type" namespace="{$_NScf}">text</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="$_validatedValue"/>
      </xsl:element>
    </xsl:if>
  </xsl:template>

<!-- Output element with URL value -->
  <xsl:template name="_OutputUrlElement">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue" select="msfeednorm:ValidateUrl(normalize-space($value))"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:element name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:element>
    </xsl:if>
  </xsl:template>

<!-- Output element with inet date value -->
  <xsl:template name="_OutputDateElement">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:param name="outFormat" select="'inetDate'"/>
    <xsl:variable name="_validatedValue">
      <xsl:choose>
        <xsl:when test="$outFormat = 'inetDate'">
          <xsl:value-of select="msfeednorm:NormalizeDateToInetDate(normalize-space($value))"/>
        </xsl:when>
        <xsl:when test="$outFormat = 'iso8601'">
          <xsl:value-of select="msfeednorm:NormalizeDateToIso8601(normalize-space($value))"/>
        </xsl:when>
      </xsl:choose>
    </xsl:variable>
    <xsl:if test="string($_validatedValue)">
      <xsl:element name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:element>
    </xsl:if>
  </xsl:template>

<!-- Output element with a non-negative number value -->
  <xsl:template name="_OutputPositiveNumberElement">
    <xsl:param name="tagName"/>
    <xsl:param name="nameSpace" select="''"/>
    <xsl:param name="value"/>
    <xsl:variable name="_validatedValue" select="number($value)"/>
    <xsl:if test="(string($_validatedValue) != 'NaN') and ($_validatedValue &gt;= 0)">
      <xsl:element name="{$tagName}" namespace="{$nameSpace}"><xsl:value-of select="$_validatedValue"/></xsl:element>
    </xsl:if>
  </xsl:template>
  
<!-- Output RSS 2.0 author or managingEditor element and convert into atom:author -->
  <xsl:template name="_OutputAuthorOrEditor">
    <xsl:param name="tagName"/>
    <xsl:param name="value"/>
    <xsl:param name="convertToAtom" select="'false'"/>
    <xsl:variable name="_validatedValue" select="normalize-space($value)"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:element name="{$tagName}"><xsl:value-of select="$_validatedValue"/></xsl:element>
      <xsl:if test="$convertToAtom = 'true'">
        <xsl:call-template name="_ConvertAuthorToAtomAuthor"><xsl:with-param name="value" select="$_validatedValue"/></xsl:call-template>
      </xsl:if>
    </xsl:if>
  </xsl:template>
  
<!-- Output atom:author or atom:contributor (have identical handling) -->
  <xsl:template name="_OutputAtomAuthorOrContributor">
    <xsl:param name="tagName"/>
    <xsl:param name="name"/>
    <xsl:param name="email"/>
    <xsl:param name="uri"/>
    <xsl:variable name="_validatedName" select="normalize-space($name)"/>
    <xsl:variable name="_validatedEmail" select="normalize-space($email)"/>
    <xsl:if test="string($_validatedName) or string($_validatedEmail)">
      <xsl:element name="{$tagName}" namespace="{$_NSatom1}">
        <xsl:if test="string($_validatedName)">
          <atom:name><xsl:value-of select="$_validatedName"/></atom:name>
        </xsl:if>
        <xsl:if test="string($_validatedEmail)">
          <atom:email><xsl:value-of select="$_validatedEmail"/></atom:email>
        </xsl:if>
        <xsl:variable name="_validatedUri" select="msfeednorm:NormalizeUri(normalize-space($uri))"/>
        <xsl:if test="string($_validatedUri)">
          <atom:uri><xsl:value-of select="$_validatedUri"/></atom:uri>
        </xsl:if>
      </xsl:element>
    </xsl:if>
  </xsl:template>



<!--
Common feed format output templates
-->

<!-- xml:lang -->
  <xsl:template name="_OutputXmlLang">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputTextAttribute">
      <xsl:with-param name="tagName" select="'xml:lang'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>
  
<!-- xml:base -->
  <xsl:template name="_OutputXmlBase">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputUrlAttribute">
      <xsl:with-param name="tagName" select="'xml:base'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- title -->
  <xsl:template name="_OutputTitle">
    <xsl:param name="value"/>
    <xsl:param name="type"/>
    <xsl:call-template name="_OutputTextElement">
      <xsl:with-param name="tagName" select="'title'"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="type" select="$type"/>
      <xsl:with-param name="outputTypeAttribute" select="'true'"/>
    </xsl:call-template>
  </xsl:template>

<!-- link -->
  <xsl:template name="_OutputLink">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputUrlElement">
      <xsl:with-param name="tagName" select="'link'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- plain-text description -->
  <xsl:template name="_OutputTextDescription">
    <xsl:param name="value"/>
    <xsl:param name="type"/>
    <xsl:call-template name="_OutputTextElement">
      <xsl:with-param name="tagName" select="'description'"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="type" select="$type"/>
      <xsl:with-param name="outputTypeAttribute" select="'true'"/>
    </xsl:call-template>
  </xsl:template>

<!-- pubDate -->
  <xsl:template name="_OutputPubDate">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputDateElement">
      <xsl:with-param name="tagName" select="'pubDate'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- language -->
  <xsl:template name="_OutputLanguage">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputTextElement">
      <xsl:with-param name="tagName" select="'language'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- copyright -->
  <xsl:template name="_OutputCopyright">
    <xsl:param name="value"/>
    <xsl:param name="type"/>
    <xsl:call-template name="_OutputTextElement">
      <xsl:with-param name="tagName" select="'copyright'"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="type" select="$type"/>
      <xsl:with-param name="outputTypeAttribute" select="'true'"/>
    </xsl:call-template>
  </xsl:template>

<!-- lastBuildDate -->
  <xsl:template name="_OutputLastBuildDate">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputDateElement">
      <xsl:with-param name="tagName" select="'lastBuildDate'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- managingEditor -->
  <xsl:template name="_OutputManagingEditor">
    <xsl:param name="value"/>
    <xsl:param name="convertToAtom" select="'false'"/>
    <xsl:call-template name="_OutputAuthorOrEditor">
      <xsl:with-param name="tagName" select="'managingEditor'"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="convertToAtom" select="$convertToAtom"/>
    </xsl:call-template>
  </xsl:template>

<!-- webMaster -->
  <xsl:template name="_OutputWebMaster">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputTextElement">
      <xsl:with-param name="tagName" select="'webMaster'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- category -->
  <xsl:template name="_OutputCategory">
    <xsl:param name="value"/>
    <xsl:param name="domain"/>
    <xsl:variable name="_validatedValue" select="normalize-space($value)"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:element name="category">
        <xsl:call-template name="_OutputTextAttribute">
          <xsl:with-param name="tagName" select="'domain'"/>
          <xsl:with-param name="value" select="$domain"/>
        </xsl:call-template>
        <xsl:value-of select="$_validatedValue"/>
      </xsl:element>
    </xsl:if>
  </xsl:template>

<!-- generator -->
  <xsl:template name="_OutputGenerator">
    <xsl:param name="value"/>
    <xsl:param name="uri"/>
    <xsl:param name="version"/>
    <xsl:variable name="_validatedValue" select="normalize-space($value)"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:element name="generator">
        <xsl:call-template name="_OutputUriAttribute">
          <xsl:with-param name="tagName" select="'cf:uri'"/>
          <xsl:with-param name="nameSpace" select="$_NScf"/>
          <xsl:with-param name="value" select="$uri"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputTextAttribute">
          <xsl:with-param name="tagName" select="'cf:version'"/>
          <xsl:with-param name="nameSpace" select="$_NScf"/>
          <xsl:with-param name="value" select="$version"/>
        </xsl:call-template>
        <xsl:value-of select="$_validatedValue"/>
      </xsl:element>
    </xsl:if>
  </xsl:template>

<!-- docs -->
  <xsl:template name="_OutputDocs">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputUrlElement">
      <xsl:with-param name="tagName" select="'docs'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- cloud -->
  <xsl:template name="_OutputCloud">
    <xsl:param name="value"/>
    <!-- We always output this element and clean any attribute it has into text -->
    <cloud>
      <xsl:for-each select="$value/@*">
        <xsl:attribute name="{name(.)}"><xsl:value-of select="normalize-space(.)"/></xsl:attribute>
      </xsl:for-each>
    </cloud>
  </xsl:template>

<!-- ttl -->
  <xsl:template name="_OutputTtl">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputPositiveNumberElement">
      <xsl:with-param name="tagName" select="'ttl'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- image -->
  <xsl:template name="_OutputImage">
    <xsl:param name="url"/>
    <xsl:param name="title"/>
    <xsl:param name="titleType" select="'text'"/>
    <xsl:param name="link"/>
    <xsl:param name="width"/>
    <xsl:param name="height"/>
    <xsl:param name="description"/>
    <xsl:param name="subnodesToCopy"/>
    <xsl:variable name="_validatedUrl" select="msfeednorm:ValidateUrl(normalize-space($url))"/>
    <xsl:if test="string($_validatedUrl)">
      <image>
        <url><xsl:value-of select="$_validatedUrl"/></url>
        <xsl:call-template name="_OutputTextElement">
          <xsl:with-param name="tagName" select="'title'"/>
          <xsl:with-param name="value" select="$title"/>
          <xsl:with-param name="type" select="$titleType"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputUrlElement">
          <xsl:with-param name="tagName" select="'link'"/>
          <xsl:with-param name="value" select="$link"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputPositiveNumberElement">
          <xsl:with-param name="tagName" select="'width'"/>
          <xsl:with-param name="value" select="$width"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputPositiveNumberElement">
          <xsl:with-param name="tagName" select="'height'"/>
          <xsl:with-param name="value" select="$height"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputTextElement">
          <xsl:with-param name="tagName" select="'description'"/>
          <xsl:with-param name="value" select="$description"/>
        </xsl:call-template>
        <xsl:if test="boolean($subnodesToCopy)">
          <xsl:for-each select="$subnodesToCopy">
            <xsl:copy-of select="."/>
          </xsl:for-each>
        </xsl:if>
      </image>
    </xsl:if>
  </xsl:template>

<!-- rating -->
  <xsl:template name="_OutputRating">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputTextElement">
      <xsl:with-param name="tagName" select="'rating'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- textInput -->
  <xsl:template name="_OutputTextInput">
    <xsl:param name="title"/>
    <xsl:param name="name"/>
    <xsl:param name="link"/>
    <xsl:param name="description"/>
    <xsl:param name="subnodesToCopy"/>
    <xsl:variable name="_validatedName" select="normalize-space($name)"/>
    <xsl:variable name="_validatedLink" select="msfeednorm:ValidateUrl(normalize-space($link))"/>
    <xsl:if test="string($_validatedName) and string($_validatedLink)">
      <textInput>
        <name><xsl:value-of select="$_validatedName"/></name>
        <link><xsl:value-of select="$_validatedLink"/></link>
        <xsl:call-template name="_OutputTextElement">
          <xsl:with-param name="tagName" select="'title'"/>
          <xsl:with-param name="value" select="$title"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputTextElement">
          <xsl:with-param name="tagName" select="'description'"/>
          <xsl:with-param name="value" select="$description"/>
        </xsl:call-template>
        <xsl:if test="boolean($subnodesToCopy)">
          <xsl:for-each select="$subnodesToCopy">
            <xsl:copy-of select="."/>
          </xsl:for-each>
        </xsl:if>
      </textInput>
    </xsl:if>
  </xsl:template>

<!-- skipHours -->
  <xsl:template name="_OutputSkipHours">
    <xsl:param name="value"/>
    <xsl:if test="$value/hour[number(.)&gt;=0 and number(.)&lt;=23]">
      <skipHours>
        <xsl:for-each select="$value/hour">
          <xsl:variable name="_numberHour" select="number(.)"/>
          <xsl:if test="$_numberHour &gt;= 0 and $_numberHour &lt;= 23">
            <hour><xsl:value-of select="$_numberHour"/></hour>
          </xsl:if>
        </xsl:for-each>
      </skipHours>
    </xsl:if>
  </xsl:template>

<!-- skipDays -->
  <xsl:template name="_OutputSkipDays">
    <xsl:param name="value"/>
    <xsl:if test="$value/day[string(.) = 'Monday' or string(.) = 'Tuesday' or string(.) = 'Wednesday' or string(.) = 'Thursday' or string(.) = 'Friday' or string(.) = 'Saturday' or string(.) = 'Sunday']">
      <skipDays>
        <xsl:for-each select="$value/day">
          <xsl:variable name="_stringDay" select="string(.)"/>
          <xsl:if test="$_stringDay = 'Monday' or $_stringDay = 'Tuesday' or $_stringDay = 'Wednesday' or $_stringDay = 'Thursday' or $_stringDay = 'Friday' or $_stringDay = 'Saturday' or $_stringDay = 'Sunday'">
            <day><xsl:value-of select="$_stringDay"/></day>
          </xsl:if>
        </xsl:for-each>
      </skipDays>
    </xsl:if>
  </xsl:template>

<!-- author -->
  <xsl:template name="_OutputAuthor">
    <xsl:param name="value"/>
    <xsl:param name="convertToAtom" select="'false'"/>
    <xsl:call-template name="_OutputAuthorOrEditor">
      <xsl:with-param name="tagName" select="'author'"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="convertToAtom" select="$convertToAtom"/>
    </xsl:call-template>
  </xsl:template>

<!-- comments -->
  <xsl:template name="_OutputComments">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputUrlElement">
      <xsl:with-param name="tagName" select="'comments'"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- enclosure -->
  <xsl:template name="_OutputEnclosure">
    <xsl:param name="url"/>
    <xsl:param name="length"/>
    <xsl:param name="type"/>
    <xsl:variable name="_validatedUrl" select="msfeednorm:ValidateUrl(normalize-space($url))"/>
    <xsl:if test="string($_validatedUrl)">
      <enclosure>
        <xsl:attribute name="url"><xsl:value-of select="$_validatedUrl"/></xsl:attribute>
        <xsl:call-template name="_OutputPositiveNumberAttribute">
          <xsl:with-param name="tagName" select="'length'"/>
          <xsl:with-param name="value" select="$length"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputMimeTypeAttribute">
          <xsl:with-param name="tagName" select="'type'"/>
          <xsl:with-param name="value" select="$type"/>
        </xsl:call-template>
      </enclosure>
    </xsl:if>
  </xsl:template>

<!-- guid -->
  <xsl:template name="_OutputGuid">
    <xsl:param name="value"/>
    <xsl:param name="isPermaLink"/>
    <xsl:param name="channelGuid" select="'false'"/>
    <xsl:variable name="_validatedValue">
      <xsl:choose>
        <xsl:when test="normalize-space($isPermaLink) = 'true' or not(string($isPermaLink))">
          <xsl:value-of select="msfeednorm:ValidateUrl(normalize-space($value))"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="string($value)"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:if test="string($_validatedValue)">
      <xsl:choose>
        <xsl:when test="$channelGuid = 'false'">
          <xsl:element name="guid">
            <xsl:call-template name="_OutputBoolAttribute">
              <xsl:with-param name="tagName" select="'isPermaLink'"/>
              <xsl:with-param name="value" select="$isPermaLink"/>
            </xsl:call-template>
            <xsl:value-of select="$_validatedValue"/>
          </xsl:element>
        </xsl:when>
        <xsl:otherwise>
          <xsl:element name="cf:guid" namespace="{$_NScf}">
            <xsl:call-template name="_OutputBoolAttribute">
              <xsl:with-param name="tagName" select="'isPermaLink'"/>
              <xsl:with-param name="value" select="$isPermaLink"/>
            </xsl:call-template>
            <xsl:value-of select="$_validatedValue"/>
          </xsl:element>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>
  
<!-- source -->
  <xsl:template name="_OutputSource">
    <xsl:param name="value"/>
    <xsl:param name="url"/>
    <xsl:variable name="_validatedValue" select="normalize-space($value)"/>
    <xsl:if test="string($_validatedValue)">
      <xsl:element name="source">
        <xsl:call-template name="_OutputUrlAttribute">
          <xsl:with-param name="tagName" select="'url'"/>
          <xsl:with-param name="value" select="$url"/>
        </xsl:call-template>
        <xsl:value-of select="$_validatedValue"/>
      </xsl:element>
    </xsl:if>
  </xsl:template>

<!-- rich-text description -->
  <xsl:template name="_OutputDescription">
    <xsl:param name="value"/>
    <xsl:param name="type"/>
    <xsl:param name="baseUrl"/>
    <!-- Description is always html -->
    <description cf:type="html">
      <xsl:call-template name="_CleanByType">
        <xsl:with-param name="value" select="$value"/>
        <xsl:with-param name="fromType" select="$type"/>
        <xsl:with-param name="toType" select="'html'"/>
        <xsl:with-param name="baseUrl" select="$baseUrl"/>
      </xsl:call-template>
    </description>
  </xsl:template>

<!-- atom:summary -->
  <xsl:template name="_OutputAtomSummary">
    <xsl:param name="value"/>
    <xsl:param name="type"/>
    <xsl:param name="xmlBase"/>
    <xsl:param name="baseUrl"/>
    <atom:summary>
      <xsl:call-template name="_OutputXmlBase"><xsl:with-param name="value" select="$xmlBase"/></xsl:call-template>
      <xsl:call-template name="_NormalizeAtomTextTypeAttr"><xsl:with-param name="value" select="$type"/></xsl:call-template>
      <xsl:call-template name="_CleanByType">
        <xsl:with-param name="value" select="$value"/>
        <xsl:with-param name="fromType" select="$type"/>
        <xsl:with-param name="toType" select="$type"/>
        <xsl:with-param name="baseUrl" select="$baseUrl"/>
      </xsl:call-template>
    </atom:summary>
  </xsl:template>

<!-- description and summary (if it exists) -->
  <xsl:template name="_OutputDescriptionAndSummary">
    <xsl:param name="description"/>
    <xsl:param name="descriptionType"/>
    <xsl:param name="descriptionBaseUrl"/>
    <xsl:param name="summary"/>
    <xsl:param name="summaryType"/>
    <xsl:param name="summaryXmlBase"/>
    <xsl:param name="summaryBaseUrl"/>
    <xsl:call-template name="_OutputDescription">
      <xsl:with-param name="value" select="$description"/>
      <xsl:with-param name="type" select="$descriptionType"/>
      <xsl:with-param name="baseUrl" select="$descriptionBaseUrl"/>
    </xsl:call-template>
    <xsl:if test="string($summary)">
      <xsl:call-template name="_OutputAtomSummary">
        <xsl:with-param name="value" select="$summary"/>
        <xsl:with-param name="type" select="$summaryType"/>
        <xsl:with-param name="xmlBase" select="$summaryXmlBase"/>
        <xsl:with-param name="baseUrl" select="$summaryBaseUrl"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

<!-- atom:link -->
  <xsl:template name="_OutputAtomLink">
    <xsl:param name="href"/>
    <xsl:param name="rel"/>
    <xsl:param name="type"/>
    <xsl:param name="title"/>
    <xsl:param name="hreflang"/>
    <xsl:param name="length"/>
    <xsl:param name="xmlBase"/>
    <xsl:variable name="_validatedHref" select="msfeednorm:ValidateUrl(normalize-space($href))"/>
    <xsl:if test="string($_validatedHref)">
      <atom:link>
        <xsl:attribute name="href"><xsl:value-of select="$_validatedHref"/></xsl:attribute>
        <xsl:call-template name="_OutputTextAttribute">
          <xsl:with-param name="tagName" select="'rel'"/>
          <xsl:with-param name="value" select="$rel"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputMimeTypeAttribute">
          <xsl:with-param name="tagName" select="'type'"/>
          <xsl:with-param name="value" select="$type"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputTextAttribute">
          <xsl:with-param name="tagName" select="'title'"/>
          <xsl:with-param name="value" select="$title"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputTextAttribute">
          <xsl:with-param name="tagName" select="'hreflang'"/>
          <xsl:with-param name="value" select="$hreflang"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputPositiveNumberAttribute">
          <xsl:with-param name="tagName" select="'length'"/>
          <xsl:with-param name="value" select="$length"/>
        </xsl:call-template>
        <xsl:call-template name="_OutputXmlBase">
          <xsl:with-param name="value" select="$xmlBase"/>
        </xsl:call-template>
      </atom:link>
    </xsl:if>
  </xsl:template>

<!-- atom:author -->
  <xsl:template name="_OutputAtomAuthor">
    <xsl:param name="name"/>
    <xsl:param name="email"/>
    <xsl:param name="uri"/>
    <xsl:call-template name="_OutputAtomAuthorOrContributor">
      <xsl:with-param name="tagName" select="'atom:author'"/>
      <xsl:with-param name="name" select="$name"/>
      <xsl:with-param name="email" select="$email"/>
      <xsl:with-param name="uri" select="$uri"/>
    </xsl:call-template>
  </xsl:template>

<!-- atom:contributor -->
  <xsl:template name="_OutputAtomContributor">
    <xsl:param name="name"/>
    <xsl:param name="email"/>
    <xsl:param name="uri"/>
    <xsl:call-template name="_OutputAtomAuthorOrContributor">
      <xsl:with-param name="tagName" select="'atom:contributor'"/>
      <xsl:with-param name="name" select="$name"/>
      <xsl:with-param name="email" select="$email"/>
      <xsl:with-param name="uri" select="$uri"/>
    </xsl:call-template>
  </xsl:template>
  
<!-- atom:published -->
  <xsl:template name="_OutputAtomPublished">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputDateElement">
      <xsl:with-param name="tagName" select="'atom:published'"/>
      <xsl:with-param name="nameSpace" select="$_NSatom1"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="outFormat" select="'iso8601'"/>
    </xsl:call-template>
  </xsl:template>
  
<!-- atom:updated -->
  <xsl:template name="_OutputAtomUpdated">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputDateElement">
      <xsl:with-param name="tagName" select="'atom:updated'"/>
      <xsl:with-param name="nameSpace" select="$_NSatom1"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="outFormat" select="'iso8601'"/>
    </xsl:call-template>
  </xsl:template>

<!-- slash:comments -->
  <xsl:template name="_OutputSlashComments">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputPositiveNumberElement">
      <xsl:with-param name="tagName" select="'slash:comments'"/>
      <xsl:with-param name="nameSpace" select="$_NSslash"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>
  
<!-- wfw:commentRss -->
  <xsl:template name="_OutputWfwCommentRSS">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputUrlElement">
      <xsl:with-param name="tagName" select="'wfw:commentRss'"/>
      <xsl:with-param name="nameSpace" select="$_NSwfw"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>
  
<!-- cf:treatAs -->
  <xsl:template name="_OutputCfTreatAs">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputTextElement">
      <xsl:with-param name="tagName" select="'cf:treatAs'"/>
      <xsl:with-param name="nameSpace" select="$_NScf"/>
      <xsl:with-param name="value" select="$value"/>
    </xsl:call-template>
  </xsl:template>

<!-- cf:listinfo -->
  <xsl:template name="_OutputCfListinfo">
    <xsl:param name="value"/>
    <cf:listinfo>
      <xsl:for-each select="$value/cf:sort">
        <xsl:variable name="_ValidatedSortElem" select="normalize-space(@element)"/>
        <xsl:variable name="_ValidatedSortLabel" select="normalize-space(@label)"/>
        <xsl:if test="string($_ValidatedSortElem) or string($_ValidatedSortLabel)">
          <cf:sort>
            <xsl:if test="string($_ValidatedSortElem)">
              <xsl:attribute name="element"><xsl:value-of select="$_ValidatedSortElem"/></xsl:attribute>
            </xsl:if>
            <xsl:if test="string($_ValidatedSortLabel)">
              <xsl:attribute name="label"><xsl:value-of select="$_ValidatedSortLabel"/></xsl:attribute>
            </xsl:if>
            <xsl:call-template name="_OutputTextAttribute">
              <xsl:with-param name="tagName" select="'ns'"/>
              <xsl:with-param name="value" select="@ns"/>
            </xsl:call-template>
            <xsl:call-template name="_OutputTextAttribute">
              <xsl:with-param name="tagName" select="'data-type'"/>
              <xsl:with-param name="value" select="@data-type"/>
            </xsl:call-template>
            <xsl:call-template name="_OutputBoolAttribute">
              <xsl:with-param name="tagName" select="'default'"/>
              <xsl:with-param name="value" select="@default"/>
            </xsl:call-template>
          </cf:sort>
        </xsl:if>
      </xsl:for-each>
      <xsl:for-each select="$value/cf:group">
        <xsl:variable name="_ValidatedGroupElem" select="normalize-space(@element)"/>
        <xsl:variable name="_ValidatedGroupLabel" select="normalize-space(@label)"/>
        <xsl:if test="string($_ValidatedGroupElem) or string($_ValidatedGroupLabel)">
          <cf:group>
            <xsl:if test="string($_ValidatedGroupElem)">
              <xsl:attribute name="element"><xsl:value-of select="$_ValidatedGroupElem"/></xsl:attribute>
            </xsl:if>
            <xsl:if test="string($_ValidatedGroupLabel)">
              <xsl:attribute name="label"><xsl:value-of select="$_ValidatedGroupLabel"/></xsl:attribute>
            </xsl:if>
            <xsl:call-template name="_OutputTextAttribute">
              <xsl:with-param name="tagName" select="'ns'"/>
              <xsl:with-param name="value" select="@ns"/>
            </xsl:call-template>
          </cf:group>
        </xsl:if>
      </xsl:for-each>
    </cf:listinfo>
  </xsl:template>

<!-- mon:expiration -->
  <xsl:template name="_OutputMonExpiration">
    <xsl:param name="value"/>
    <xsl:call-template name="_OutputDateElement">
      <xsl:with-param name="tagName" select="'mon:expiration'"/>
      <xsl:with-param name="nameSpace" select="$_NSmon"/>
      <xsl:with-param name="value" select="$value"/>
      <xsl:with-param name="outFormat" select="'iso8601'"/>
    </xsl:call-template>
  </xsl:template>
  
<!-- output the extension nodes -->
  <xsl:template name="_OutputExtension">
    <xsl:param name="value"/>
    <xsl:param name="references"/>
    <xsl:if test="namespace-uri($value) != $_NScfi">
      <xsl:variable name="nodeRefName">'<xsl:value-of select="namespace-uri($value)"/>':<xsl:value-of select="local-name($value)"/>;</xsl:variable>
      <xsl:choose>
        <xsl:when test="string($references) and contains($references, $nodeRefName)">
          <xsl:call-template name="_OutputTextElement">
            <xsl:with-param name="value" select="$value"/>
            <xsl:with-param name="tagName" select="name($value)"/>
            <xsl:with-param name="nameSpace" select="namespace-uri($value)"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="$value"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>
  </xsl:template>

</xsl:stylesheet>
PAPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADDINGXXPADDINGPADD