Следующий мой вывод основан на моем xslt-коде, который я наклеил ниже. Этот выход повторяется ext: PersonBirthDate. Я хочу удалить первый и последний ext: PersonBirthDate Я хочу иметь только 3 extPersonBirthdate , но не родительский. Как это сделать? Вот выходКак удалить родительский узел из вывода?
<ext:PersonBirthDate>
<ext:PersonBirthDate approximateDateIndicator="true" currentIndicator="false">1956-03-04</ext:PersonBirthDate>
<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="false">1956-04-21</ext:PersonBirthDate>
<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1956-05-21</ext:PersonBirthDate>
</ext:PersonBirthDate>
Я хочу, чтобы мой выход выглядеть как этот
<ext:PersonBirthDate ext:approximateDateIndicator="true" ext:currentIndicator="false">1956-03-04</ext:PersonBirthDate>
<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="false">1956-04-21</ext:PersonBirthDate>
<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1956-05-21</ext:PersonBirthDate>
Мой входной XML-документ с большим количеством кода
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="BCA PO Notification" MessageID="57810746" xmlns="">
<ControlPoint Timestamp="11/12/2014 12:29:07 PM" UserID="KimaniW">SAVE-PROTECTION-ORDER</ControlPoint>
<Case InternalID="1616758667" ID="11681295" xmlns:user="http://tylertechnologies.com">
<FiledDate>10/30/2014</FiledDate>
<CaseCategory>FAM</CaseCategory>
<CaseType Word="DMA">Domestic Abuse</CaseType>
<BaseCaseType>Civil Domestic Violence</BaseCaseType>
<CaseTitle>In the Matter of Randy Carl Shogren vs Faith Marie Dieter</CaseTitle>
<SecurityGroup Word="CONFPOR">Conf - Protective Order</SecurityGroup>
<Active>true</Active>
<Deleted>false</Deleted>
<Expunged>false</Expunged>
<CaseNumber>10-FA-14-118</CaseNumber>
<Court>
<NodeID>111</NodeID>
<CourtName>Carver County</CourtName>
<CourtNCIC>MN010015J</CourtNCIC>
</Court>
<Assignment Current="true">
<Court>
<NodeID>111</NodeID>
<CourtName>Carver County</CourtName>
<CourtNCIC>MN010015J</CourtNCIC>
</Court>
<CaseNumber>10-FA-14-118</CaseNumber>
<AssignmentDate>10/30/2014</AssignmentDate>
<NoticeJudicialOfficer>false</NoticeJudicialOfficer>
<TimestampCreate>10/30/2014 13:21:50:077</TimestampCreate>
</Assignment>
<CaseParty ID="14474176" InternalCasePartyID="1633582774" InternalPartyID="1612366618">
<ObservedRace Word="A">Asian</ObservedRace>
<Connection Word="RSP" BaseConnection="DF" ID="34642711" InternalCasePartyConnectionID="1635190267">
<Description>Respondent</Description>
</Connection>
<CasePartyName Current="true" ID="5194942" InternalNameID="1612772263">
<FormattedName>Jana, Deoe Madue</FormattedName>
</CasePartyName>
</CaseParty>
</Case>
<Party ID="14474176" InternalPartyID="1612366618">
<Gender Word="F ">Female</Gender>
<ApproximateDOB>3/4/1956</ApproximateDOB>
<DateOfBirth>04/21/1956</DateOfBirth>
<DateOfBirth Current="true">05/21/1956</DateOfBirth>
<PartyName ID="5194942" Current="true" InternalNameID="1612772263">
<FormattedName>Jana, Deoe Madue</FormattedName>
</PartyName>
<PersonID>
<PersonIDNumber ID="3554946"/>
<PersonIDGroup>Person-ID</PersonIDGroup>
</PersonID>
</Party>
<ProtectionOrder Op="E" InternalProtectionOrderID="1305" xmlns:user="http://tylertechnologies.com">
<RespondentPartyID InternalPartyID="1612366618">1612366618</RespondentPartyID>
<RespondentNameID InternalNameID="1612772263">1612772263</RespondentNameID>
</ProtectionOrder>
</Integration>
Вот мой x SLT, который имеет больше кода
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://www.courts.state.dc.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:mscef="courts.state.dc.us/extfun" extension-element-prefixes="exsl" exclude-result-prefixes="mscef msxsl exsl"
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template name="ProtectionOrder">
<ext:ProtectionOrder>
<!--Respondent -->
<xsl:for-each select="RespondentPartyID">
<xsl:for-each select="//CaseParty[(@InternalPartyID=current()/@InternalPartyID) and (Connection[(@Word='RSP') ])]">
<xsl:for-each select="//Party[@InternalPartyID=current()/@InternalPartyID]">
<xsl:call-template name="Respondent">
<xsl:with-param name="pProtectionOrderID">
<xsl:value-of select="$vProtectionOrderID"/>
</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</ext:ProtectionOrder>
</xsl:template>
<!--
Template for DateOfBirth for the respondent
-->
<xsl:template match="DateOfBirth">
<ext:PersonBirthDate>
<xsl:attribute name="ext:approximateDateIndicator">false</xsl:attribute>
<xsl:attribute name="ext:currentIndicator">false</xsl:attribute>
<xsl:value-of select="mscef:formatDate(string(.))"/>
</ext:PersonBirthDate>
</xsl:template>
<!--Template for DateOfBirth or the respondent where Current = true -->
<xsl:template match="DateOfBirth[@Current='true']">
<ext:PersonBirthDate>
<xsl:attribute name="ext:approximateDateIndicator">false</xsl:attribute>
<xsl:attribute name="ext:currentIndicator">true</xsl:attribute>
<xsl:value-of select="mscef:formatDate(string(.))"/>
</ext:PersonBirthDate>
</xsl:template>
<!--Template for ApproximateDOB -->
<xsl:template match="ApproximateDOB">
<ext:PersonBirthDate approximateDateIndicator="true" currentIndicator="{not(../DateOfBirth)}" >
<xsl:value-of select="mscef:formatDate(string(.))"/>
</ext:PersonBirthDate>
</xsl:template>
<!--Respondent Template-->
<xsl:template name="Respondent">
<xsl:param name="pProtectionOrderID"/>
<ext:Respondent>
<nc:PersonEthnicityCode>
<xsl:choose>
<xsl:when test="//CaseParty[@ID=current()/@ID]/ObservedEthnicity/@Word='NH'">N</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@Word"/>
</xsl:otherwise>
</xsl:choose>
</nc:PersonEthnicityCode>
<nc:PersonEyeColorCode>
<xsl:value-of select="EyeColor/@Word"/>
</nc:PersonEyeColorCode>
<nc:PersonHairColorCode>
<xsl:for-each select="Gender">
<nc:PersonSexCode>
<xsl:value-of select="@Word"/>
</nc:PersonSexCode>
</xsl:for-each>
<!--Guardian who is the respondent-->
<xsl:for-each select="//CaseParty[(Connection[(@Word='GRD')])][1]">
<xsl:for-each select="//Party[@InternalPartyID=current()/@InternalPartyID]">
<xsl:call-template name="Guardian"/>
</xsl:for-each>
</xsl:for-each>
<ext:PersonBirthDate>
<xsl:apply-templates select="ApproximateDOB|DateOfBirth"/>
</ext:PersonBirthDate>
<xsl:for-each select="PartyName[@Current='true']">
<ext:PersonName>
<xsl:attribute name="ext:currentIndicator"><xsl:value-of select="@Current"/></xsl:attribute>
<nc:PersonFullName>
<xsl:value-of select="FormattedName"/>
</nc:PersonFullName>
</ext:PersonName>
</xsl:for-each>
</ext:Respondent>
</xsl:template>
<!--Guardian Template-->
<xsl:template name="Guardian">
<ext:Guardian>
<ext:AddressReference>
<xsl:for-each select="//Address[@PartyCurrent='true']">
<xsl:attribute name="ext:currentIndicator"><xsl:value-of select="@PartyCurrent"/></xsl:attribute>
</xsl:for-each>
<nc:LocationReference>
<xsl:attribute name="s:ref"><xsl:text>INT</xsl:text><xsl:value-of select="Address/@ID"/></xsl:attribute>
</nc:LocationReference>
</ext:AddressReference>
<ext:PersonBirthDate>
<xsl:choose>
<xsl:when test="DateOfBirth[@Current='true']">
<xsl:attribute name="ext:approximateDateIndicator">false</xsl:attribute>
<xsl:attribute name="ext:currentIndicator">true</xsl:attribute>
<xsl:value-of select="mscef:formatDate(string(DateOfBirth[@Current='true']))"/>
</xsl:when>
<xsl:when test="ApproximateDOB">
<xsl:attribute name="ext:approximateDateIndicator">true</xsl:attribute>
<xsl:attribute name="ext:currentIndicator">true</xsl:attribute>
<xsl:value-of select="mscef:formatDate(string(ApproximateDOB))"/>
</xsl:when>
</xsl:choose>
</ext:PersonBirthDate>
<xsl:for-each select="PartyName[@Current='true']">
<nc:PersonName>
<nc:PersonFullName>
<xsl:value-of select="FormattedName"/>
</nc:PersonFullName>
</nc:PersonName>
</xsl:for-each>
<xsl:for-each select="Gender">
<nc:PersonSexCode>
<xsl:value-of select="@Word"/>
</nc:PersonSexCode>
</xsl:for-each>
</ext:Guardian>
</xsl:template>
</xsl:stylesheet>
Можем ли мы иметь полный образец ввода (если он больше) и полный xslt (какой шаблон вызывает ответчик, например)? –
Это нормально для вас, что у вас есть в ожидаемых выходных атрибутах с префиксом имени и другими без него (то есть: ext: currentIndicator vs currentIndicator)? –
Атрибут currentIndicator должен иметь префикс ext. Я забыл добавить его в шаблон ApproximateDOB для респондента. Я добавил его в свой код. Я отредактировал выше и добавил полный образец xml и полный xslt с вызовом шаблона для респондента. – user3781064