C#仅查询xslt的父节点

C#仅查询xslt的父节点,c#,.net,linq,xslt,C#,.net,Linq,Xslt,我有以下xslt:- <IncidentTicket ExternalSystemName="{ExternalSystemName}" Company="$Company"> <xsl:if test="{Incident-LastResolvedDate} and {Incident-LastResolvedDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:attrib

我有以下xslt:-

<IncidentTicket ExternalSystemName="{ExternalSystemName}" Company="$Company">
<xsl:if test="{Incident-LastResolvedDate} and {Incident-LastResolvedDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="LastResolvedDate">
      <xsl:value-of select="{Incident-LastResolvedDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ServiceType} and {Incident-ServiceType} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ServiceType">
      <xsl:value-of select="'Incident'" />
    </xsl:attribute>
  </xsl:if>
<ExternalRelease>
<xsl:if test="incTest4 and incTest4 != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:attribute name="TestDate">
<xsl:value-of select="incTest4" />
</xsl:attribute>
</xsl:if>
</ExternalRelease>
</IncidentTicket>
当它进入ExternalRelease节点时,它总是返回True

当我查询时,我不想使用像ExternalRelease这样的子节点,我只想在IncidentTicket中进行检查

我怎样才能做到这一点

结果内容:-

<IncidentTicket ExternalSystemName="{ExternalSystemName}" Company="$Company">
  <xsl:if test="{Incident-LastResolvedDate} and {Incident-LastResolvedDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="LastResolvedDate">
      <xsl:value-of select="{Incident-LastResolvedDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ServiceType} and {Incident-ServiceType} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ServiceType">
      <xsl:value-of select="'Incident'" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-IncidentNumber} and {Incident-IncidentNumber} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="IncidentNumber">
      <xsl:value-of select="{Incident-IncidentNumber}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ReportedDateTime} and {Incident-ReportedDateTime} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ReportedDateTime">
      <xsl:value-of select="{Incident-ReportedDateTime}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-LastModifiedTime} and {Incident-LastModifiedTime} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="LastModifiedTime">
      <xsl:value-of select="{Incident-LastModifiedTime}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Priority} and {Incident-Priority} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Priority">
      <xsl:value-of select="{Incident-Priority}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Status} and {Incident-Status} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Status">
      <xsl:value-of select="{Incident-Status}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-TicketDescription} and {Incident-TicketDescription} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="TicketDescription">
      <xsl:value-of select="{Incident-TicketDescription}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-AssigneeLoginId} and {Incident-AssigneeLoginId} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="AssigneeLoginId">
      <xsl:value-of select="{Incident-AssigneeLoginId}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-DueDate} and {Incident-DueDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="DueDate">
      <xsl:value-of select="{Incident-DueDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-SupportGroupName} and {Incident-SupportGroupName} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="SupportGroupName">
      <xsl:value-of select="{Incident-SupportGroupName}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ResolutionDescription} and {Incident-ResolutionDescription} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ResolutionDescription">
      <xsl:value-of select="{Incident-ResolutionDescription}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Category} and {Incident-Category} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Category">
      <xsl:value-of select="{Incident-Category}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ClosedDate} and {Incident-ClosedDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ClosedDate">
      <xsl:value-of select="{Incident-ClosedDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ReportedSource} and {Incident-ReportedSource} != 'null'" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ReportedSource">
      <xsl:value-of select="{Incident-ReportedSource}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-CreatedBy} and {Incident-CreatedBy} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="CreatedBy">
      <xsl:value-of select="{Incident-CreatedBy}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-LongDescription} and {Incident-LongDescription} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="LongDescription">
      <xsl:value-of select="{Incident-LongDescription}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-CallerId} and {Incident-CallerId} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="CallerId">
      <xsl:value-of select="{Incident-CallerId}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Impact} and {Incident-Impact} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Impact">
      <xsl:value-of select="{Incident-Impact}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Urgency} and {Incident-Urgency} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Urgency">
      <xsl:value-of select="{Incident-Urgency}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-CorrelationId} and {Incident-CorrelationId} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="CorrelationId">
      <xsl:value-of select="{Incident-CorrelationId}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-RelatedIncidents} and {Incident-RelatedIncidents} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="RelatedIncidents">
      <xsl:value-of select="{Incident-RelatedIncidents}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-RelatedProblems} and {Incident-RelatedProblems} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="RelatedProblems">
      <xsl:value-of select="{Incident-RelatedProblems}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-RelatedTasks} and {Incident-RelatedTasks}!= ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="RelatedTasks">
      <xsl:value-of select="{Incident-RelatedTasks}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ResponseDueDate} and {Incident-ResponseDueDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ResponseDueDate">
      <xsl:value-of select="{Incident-ResponseDueDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ResolutionDueDate} and {Incident-ResolutionDueDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ResolutionDueDate">
      <xsl:value-of select="{Incident-ResolutionDueDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ConfigurationItem} and {Incident-ConfigurationItem}!= ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ConfigurationItem">
      <xsl:value-of select="{Incident-ConfigurationItem}" />
    </xsl:attribute>
  </xsl:if>
                  {Incident-TestCondition}
                  {Attr-Incident}

                <ExternalRelease><xsl:if test="incTest4 and incTest4 != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:attribute name="TestDate"><xsl:value-of select="incTest4" /></xsl:attribute></xsl:if></ExternalRelease></IncidentTicket>

{事件测试条件}
{Attr事件}

使用
元素()
而不是
子体()
使用
元素()
而不是
子体()

结果.元素().Attributes(“名称”)。其中(x=>x.Value==“TestDate”)。每次这都会给我假。。即使元素存在,它也会返回falsePost结果contentposted。。请看一看onceExternalRelease节点不是静态的,它可以包含任何nameAttribute Name=“TestDate”result.Elements().Attributes(“Name”)。其中(x=>x.Value==“TestDate”)。任何()每次这都会给我false。。即使元素存在,它也会返回falsePost结果contentposted。。请看一下onceExternalRelease节点不是静态的,它可以包含任何nameAttribute Name=“TestDate”
<IncidentTicket ExternalSystemName="{ExternalSystemName}" Company="$Company">
  <xsl:if test="{Incident-LastResolvedDate} and {Incident-LastResolvedDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="LastResolvedDate">
      <xsl:value-of select="{Incident-LastResolvedDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ServiceType} and {Incident-ServiceType} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ServiceType">
      <xsl:value-of select="'Incident'" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-IncidentNumber} and {Incident-IncidentNumber} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="IncidentNumber">
      <xsl:value-of select="{Incident-IncidentNumber}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ReportedDateTime} and {Incident-ReportedDateTime} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ReportedDateTime">
      <xsl:value-of select="{Incident-ReportedDateTime}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-LastModifiedTime} and {Incident-LastModifiedTime} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="LastModifiedTime">
      <xsl:value-of select="{Incident-LastModifiedTime}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Priority} and {Incident-Priority} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Priority">
      <xsl:value-of select="{Incident-Priority}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Status} and {Incident-Status} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Status">
      <xsl:value-of select="{Incident-Status}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-TicketDescription} and {Incident-TicketDescription} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="TicketDescription">
      <xsl:value-of select="{Incident-TicketDescription}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-AssigneeLoginId} and {Incident-AssigneeLoginId} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="AssigneeLoginId">
      <xsl:value-of select="{Incident-AssigneeLoginId}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-DueDate} and {Incident-DueDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="DueDate">
      <xsl:value-of select="{Incident-DueDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-SupportGroupName} and {Incident-SupportGroupName} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="SupportGroupName">
      <xsl:value-of select="{Incident-SupportGroupName}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ResolutionDescription} and {Incident-ResolutionDescription} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ResolutionDescription">
      <xsl:value-of select="{Incident-ResolutionDescription}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Category} and {Incident-Category} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Category">
      <xsl:value-of select="{Incident-Category}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ClosedDate} and {Incident-ClosedDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ClosedDate">
      <xsl:value-of select="{Incident-ClosedDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ReportedSource} and {Incident-ReportedSource} != 'null'" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ReportedSource">
      <xsl:value-of select="{Incident-ReportedSource}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-CreatedBy} and {Incident-CreatedBy} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="CreatedBy">
      <xsl:value-of select="{Incident-CreatedBy}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-LongDescription} and {Incident-LongDescription} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="LongDescription">
      <xsl:value-of select="{Incident-LongDescription}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-CallerId} and {Incident-CallerId} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="CallerId">
      <xsl:value-of select="{Incident-CallerId}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Impact} and {Incident-Impact} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Impact">
      <xsl:value-of select="{Incident-Impact}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-Urgency} and {Incident-Urgency} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="Urgency">
      <xsl:value-of select="{Incident-Urgency}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-CorrelationId} and {Incident-CorrelationId} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="CorrelationId">
      <xsl:value-of select="{Incident-CorrelationId}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-RelatedIncidents} and {Incident-RelatedIncidents} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="RelatedIncidents">
      <xsl:value-of select="{Incident-RelatedIncidents}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-RelatedProblems} and {Incident-RelatedProblems} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="RelatedProblems">
      <xsl:value-of select="{Incident-RelatedProblems}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-RelatedTasks} and {Incident-RelatedTasks}!= ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="RelatedTasks">
      <xsl:value-of select="{Incident-RelatedTasks}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ResponseDueDate} and {Incident-ResponseDueDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ResponseDueDate">
      <xsl:value-of select="{Incident-ResponseDueDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ResolutionDueDate} and {Incident-ResolutionDueDate} != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ResolutionDueDate">
      <xsl:value-of select="{Incident-ResolutionDueDate}" />
    </xsl:attribute>
  </xsl:if>
  <xsl:if test="{Incident-ConfigurationItem} and {Incident-ConfigurationItem}!= ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:attribute name="ConfigurationItem">
      <xsl:value-of select="{Incident-ConfigurationItem}" />
    </xsl:attribute>
  </xsl:if>
                  {Incident-TestCondition}
                  {Attr-Incident}

                <ExternalRelease><xsl:if test="incTest4 and incTest4 != ''" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:attribute name="TestDate"><xsl:value-of select="incTest4" /></xsl:attribute></xsl:if></ExternalRelease></IncidentTicket>