开发者

Xsl: xsl:value-of and email addresses

It has been a long time since I have written XSL, I have this template:

<xsl:template match="TeamMember" mode="author">
    <xsl:element name="author">
      <xsl:attribute name="email">
        <xsl:value-of select="Email" />
      </xsl:attribute>
      <xsl:value-of select="Email" />
      <xsl:value-of select="DisplayName" />
    </xsl:element>      
  </xsl:template>

Which seems to work OK, except one thing. It will output the "Email" within the Element BUT not as the attribute. The XML Snippet beign matched against looks like:

<TeamMember sequence="1" primaryIndicator="Yes" personID="102">
  <Role rank="1">Analyst</Role> 
  <LastName>YYY</LastName> 
  <FirstName>XXX</FirstName> 
  <MiddleName /> 
  <Position /> 
  &开发者_运维百科lt;ClientCode /> 
  <Division ID="1" code="Equity Research" name="Equity Research" /> 
  <Office ID="1" name="" time_zone_name="(GMT-5:00) Eastern Time (US & Canada)" time_zone_short="EST" /> 
  <DisplayName>XXX YYY</DisplayName> 
  <Phone></Phone> 
  <Email>XXX.YYY@ZZZ.com</Email>
</TeamMember>

I am using .NET 4.0.


Nevermind. It was an upstream bug. Sorry.


I would better use:

<xsl:template match="TeamMember" mode="author"> 
    <author email="{Email}"> 
      <xsl:value-of select="DisplayName" /> 
    </author>       
</xsl:template>

Note: Attribute Value Template.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜