1

我有以下 XML

<ExternalAssessmentRequest>

</ExternalAssessmentRequest>

如果有人可以帮助我,真的很感谢你的帮助。问候

4

4 回答 4

2

这是一个带有查找表的解决方案,您可以自己填写:

t:\ftemp>type plural.xml 
<ExternalAssessmentRequest>
    <ApplicationData Lender="MegaBank">
        <LiabilityList>
            <RequestedLoans>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
                <Features Code="Test"/>
            </RequestedLoans>
            <ExistingLoans>
                <Securities RelatedIdentifier="Test"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </ExistingLoans>
            <OtherLiabilities >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </OtherLiabilities>
            <Expenses Amount="50" Description="Train Ticket" Identifier="Expense1" NonRecurring="Yes" Type="Transport" Year="2013">
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Expenses>
        </LiabilityList>
        <AssetList>
            <Assets >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Assets>
            <Funds Amount="1000" Description="Slush Fund" Identifier="Fund1"/>
        </AssetList>
        <IncomeList>
            <Incomes >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Incomes>
        </IncomeList>
        <ApplicantList>
            <Households AdditionalAdults="0" Boarding="Yes" Children="0" Description="1 Test St, Sydney" Postcode="2000">
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant1" Name="John Smith" Partner="Applicant2" Partnered="Yes" PermanentResident="Yes"/>
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant2" Name="Jane Smith" Partner="Applicant1" Partnered="Yes" PermanentResident="Yes"/>
                <Guarantors/>
            </Households>
            <Companies Identifier="Company1" Name="Tardis">
                <Directors RelatedIdentifier="Applicant1"/>
            </Companies>
        </ApplicantList>
        <FeeList>
            <Fees Amount="100" Capitalised="Yes" DateOfPayment="1967-08-13" Description="Application Fee" Identifier="Fee1" PaidAmount="0"/>
        </FeeList>
    </ApplicationData>
    <AdditionalAssessments Lender="MegaBank">
        <RequestedLoans Product="Supa Variable" ProductID="Product2"/>
    </AdditionalAssessments>
</ExternalAssessmentRequest>
t:\ftemp>call xslt2 plural.xml plural.xsl 
<?xml version="1.0" encoding="UTF-8"?><ExternalAssessmentRequest>
    <ApplicationData Lender="MegaBank">
        <LiabilityList>
            <RequestedLoan>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
                <Features Code="Test"/>
            </RequestedLoan>
            <ExistingLoans>
                <Securities RelatedIdentifier="Test"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </ExistingLoans>
            <OtherLiabilities>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </OtherLiabilities>
            <Expenses Amount="50" Description="Train Ticket" Identifier="Expense1" NonRecurring="Yes" Type="Transport" Year="2013">
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Expenses>
        </LiabilityList>
        <AssetList>
            <Assets>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Assets>
            <Funds Amount="1000" Description="Slush Fund" Identifier="Fund1"/>
        </AssetList>
        <IncomeList>
            <Incomes>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Incomes>
        </IncomeList>
        <ApplicantList>
            <Households AdditionalAdults="0" Boarding="Yes" Children="0" Description="1 Test St, Sydney" Postcode="2000">
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant1" Name="John Smith" Partner="Applicant2" Partnered="Yes" PermanentResident="Yes"/>
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant2" Name="Jane Smith" Partner="Applicant1" Partnered="Yes" PermanentResident="Yes"/>
                <Guarantors/>
            </Households>
            <Company Identifier="Company1" Name="Tardis">
                <Directors RelatedIdentifier="Applicant1"/>
            </Company>
        </ApplicantList>
        <FeeList>
            <Fees Amount="100" Capitalised="Yes" DateOfPayment="1967-08-13" Description="Application Fee" Identifier="Fee1" PaidAmount="0"/>
        </FeeList>
    </ApplicationData>
    <AdditionalAssessments Lender="MegaBank">
        <RequestedLoan Product="Supa Variable" ProductID="Product2"/>
    </AdditionalAssessments>
</ExternalAssessmentRequest>
t:\ftemp>type plural.xsl 
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:data="urn:X-data"
                exclude-result-prefixes="xsd data"
                version="2.0">

<data:convert>
  <convert old="RequestedLoans" new="RequestedLoan"/>
  <convert old="Companies" new="Company"/>
  ...add more here...
</data:convert>

<xsl:key name="converts" match="convert" use="@old"/>

<xsl:template match="*[key('converts',name(.),document(''))]">
  <xsl:element name="{key('converts',name(.),document(''))/@new}"
               namespace="{namespace-uri()}">
    <xsl:apply-templates select="@*,node()"/>
  </xsl:element>
</xsl:template>

<xsl:template match="@*|node()"><!--identity for all other nodes-->
  <xsl:copy>
    <xsl:apply-templates select="@*,node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>rem Done! 

编辑以确保在一般解决方案中保留命名空间,而不是假设元素不在命名空间中。感谢 Mads 在他发布的解决方案中首先这样做。

于 2013-09-19T00:40:39.120 回答
1

答案的 XSLT 1.0 版本,没有解决与其他答案讨论的命名空间问题。简化的假设是新旧名称列表不会更改名称空间前缀,并且使用与输入源文件相同的名称空间前缀。

t:\ftemp>type plural.xml 
<ExternalAssessmentRequest>
    <ApplicationData Lender="MegaBank">
        <LiabilityList>
            <RequestedLoans>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
                <Features Code="Test"/>
            </RequestedLoans>
            <ExistingLoans>
                <Securities RelatedIdentifier="Test"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </ExistingLoans>
            <OtherLiabilities >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </OtherLiabilities>
            <Expenses Amount="50" Description="Train Ticket" Identifier="Expense1" NonRecurring="Yes" Type="Transport" Year="2013">
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Expenses>
        </LiabilityList>
        <AssetList>
            <Assets >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Assets>
            <Funds Amount="1000" Description="Slush Fund" Identifier="Fund1"/>
        </AssetList>
        <IncomeList>
            <Incomes >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Incomes>
        </IncomeList>
        <ApplicantList>
            <Households AdditionalAdults="0" Boarding="Yes" Children="0" Description="1 Test St, Sydney" Postcode="2000">
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant1" Name="John Smith" Partner="Applicant2" Partnered="Yes" PermanentResident="Yes"/>
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant2" Name="Jane Smith" Partner="Applicant1" Partnered="Yes" PermanentResident="Yes"/>
                <Guarantors/>
            </Households>
            <Companies Identifier="Company1" Name="Tardis">
                <Directors RelatedIdentifier="Applicant1"/>
            </Companies>
        </ApplicantList>
        <FeeList>
            <Fees Amount="100" Capitalised="Yes" DateOfPayment="1967-08-13" Description="Application Fee" Identifier="Fee1" PaidAmount="0"/>
        </FeeList>
    </ApplicationData>
    <AdditionalAssessments Lender="MegaBank">
        <RequestedLoans Product="Supa Variable" ProductID="Product2"/>
    </AdditionalAssessments>
</ExternalAssessmentRequest>
t:\ftemp>call xslt plural.xml plural.xsl 
<?xml version="1.0" encoding="utf-8"?><ExternalAssessmentRequest>
    <ApplicationData Lender="MegaBank">
        <LiabilityList>
            <RequestedLoan>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
                <Features Code="Test"/>
            </RequestedLoan>
            <ExistingLoans>
                <Securities RelatedIdentifier="Test"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </ExistingLoans>
            <OtherLiabilities>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </OtherLiabilities>
            <Expenses Amount="50" Description="Train Ticket" Identifier="Expense1" NonRecurring="Yes" Type="Transport" Year="2013">
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Expenses>
        </LiabilityList>
        <AssetList>
            <Assets>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Assets>
            <Funds Amount="1000" Description="Slush Fund" Identifier="Fund1"/>
        </AssetList>
        <IncomeList>
            <Incomes>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Incomes>
        </IncomeList>
        <ApplicantList>
            <Households AdditionalAdults="0" Boarding="Yes" Children="0" Description="1 Test St, Sydney" Postcode="2000">
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant1" Name="John Smith" Partner="Applicant2" Partnered="Yes" PermanentResident="Yes"/>
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant2" Name="Jane Smith" Partner="Applicant1" Partnered="Yes" PermanentResident="Yes"/>
                <Guarantors/>
            </Households>
            <Company Identifier="Company1" Name="Tardis">
                <Directors RelatedIdentifier="Applicant1"/>
            </Company>
        </ApplicantList>
        <FeeList>
            <Fees Amount="100" Capitalised="Yes" DateOfPayment="1967-08-13" Description="Application Fee" Identifier="Fee1" PaidAmount="0"/>
        </FeeList>
    </ApplicationData>
    <AdditionalAssessments Lender="MegaBank">
        <RequestedLoan Product="Supa Variable" ProductID="Product2"/>
    </AdditionalAssessments>
</ExternalAssessmentRequest>
t:\ftemp>type plural.xsl 
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:data="urn:X-data"
                exclude-result-prefixes="data"
                version="1.0">

<data:convert>
  <convert old="RequestedLoans" new="RequestedLoan"/>
  <convert old="Companies" new="Company"/>
  ...add more here...
</data:convert>

<xsl:key name="converts" match="convert" use="@old"/>

<xsl:template match="*[name(.)=document('')/*/data:convert/convert/@old]">
  <xsl:variable name="here" select="."/>
  <xsl:for-each select="document('')">
    <xsl:element name="{key('converts',name($here))/@new}"
                 namespace="{namespace-uri()}">
      <xsl:apply-templates select="$here/@*|$here/node()"/>
    </xsl:element>
  </xsl:for-each>
</xsl:template>

<xsl:template match="@*|node()"><!--identity for all other nodes-->
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>rem Done! 
于 2013-09-19T13:12:18.260 回答
1

你没有展示你已经尝试过的东西。再一次,我们不知道您是在向我们寻求指导,还是在要求我们为您完成工作。

下面的示例对复数做出以下假设,如果您有更多,则由您决定:

  • “是”->“是”
  • "s" -> ""

如果您列举了您想要适应的所有“复数到单数”规则,那将会有所帮助。例如,如果您有一个名为的元素,<Class>那么下面的样式表会将其损坏为<Clas>. 拼写中的“复数”概念一点也不简单。我建议您使用查找表并枚举您想要的更改。

同样,你的问题不完整,你给志愿者额外的时间提供帮助。

t:\ftemp>type plural.xml 
<ExternalAssessmentRequest>
    <ApplicationData Lender="MegaBank">
        <LiabilityList>
            <RequestedLoans>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
                <Features Code="Test"/>
            </RequestedLoans>
            <ExistingLoans>
                <Securities RelatedIdentifier="Test"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </ExistingLoans>
            <OtherLiabilities >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </OtherLiabilities>
            <Expenses Amount="50" Description="Train Ticket" Identifier="Expense1" NonRecurring="Yes" Type="Transport" Year="2013">
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Expenses>
        </LiabilityList>
        <AssetList>
            <Assets >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Assets>
            <Funds Amount="1000" Description="Slush Fund" Identifier="Fund1"/>
        </AssetList>
        <IncomeList>
            <Incomes >
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicants Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Incomes>
        </IncomeList>
        <ApplicantList>
            <Households AdditionalAdults="0" Boarding="Yes" Children="0" Description="1 Test St, Sydney" Postcode="2000">
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant1" Name="John Smith" Partner="Applicant2" Partnered="Yes" PermanentResident="Yes"/>
                <Persons CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant2" Name="Jane Smith" Partner="Applicant1" Partnered="Yes" PermanentResident="Yes"/>
                <Guarantors/>
            </Households>
            <Companies Identifier="Company1" Name="Tardis">
                <Directors RelatedIdentifier="Applicant1"/>
            </Companies>
        </ApplicantList>
        <FeeList>
            <Fees Amount="100" Capitalised="Yes" DateOfPayment="1967-08-13" Description="Application Fee" Identifier="Fee1" PaidAmount="0"/>
        </FeeList>
    </ApplicationData>
    <AdditionalAssessments Lender="MegaBank">
        <RequestedLoans Product="Supa Variable" ProductID="Product2"/>
    </AdditionalAssessments>
</ExternalAssessmentRequest>
t:\ftemp>call xslt2 plural.xml plural.xsl 
<?xml version="1.0" encoding="UTF-8"?><ExternalAssessmentRequest>
    <ApplicationData Lender="MegaBank">
        <LiabilityList>
            <RequestedLoan>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant2"/>
                <Feature Code="Test"/>
            </RequestedLoan>
            <ExistingLoan>
                <Security RelatedIdentifier="Test"/>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </ExistingLoan>
            <OtherLiability>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </OtherLiability>
            <Expense Amount="50" Description="Train Ticket" Identifier="Expense1" NonRecurring="Yes" Type="Transport" Year="2013">
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Expense>
        </LiabilityList>
        <AssetList>
            <Asset>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Asset>
            <Fund Amount="1000" Description="Slush Fund" Identifier="Fund1"/>
        </AssetList>
        <IncomeList>
            <Income>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant1"/>
                <Applicant Percentage="0.5" RelatedIdentifier="Applicant2"/>
            </Income>
        </IncomeList>
        <ApplicantList>
            <Household AdditionalAdults="0" Boarding="Yes" Children="0" Description="1 Test St, Sydney" Postcode="2000">
                <Person CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant1" Name="John Smith" Partner="Applicant2" Partnered="Yes" PermanentResident="Yes"/>
                <Person CountryOfResidence="Australia" CustomerDurationInMonths="0" DischargedBankrupts="0" Identifier="Applicant2" Name="Jane Smith" Partner="Applicant1" Partnered="Yes" PermanentResident="Yes"/>
                <Guarantor/>
            </Household>
            <Company Identifier="Company1" Name="Tardis">
                <Director RelatedIdentifier="Applicant1"/>
            </Company>
        </ApplicantList>
        <FeeList>
            <Fee Amount="100" Capitalised="Yes" DateOfPayment="1967-08-13" Description="Application Fee" Identifier="Fee1" PaidAmount="0"/>
        </FeeList>
    </ApplicationData>
    <AdditionalAssessment Lender="MegaBank">
        <RequestedLoan Product="Supa Variable" ProductID="Product2"/>
    </AdditionalAssessment>
</ExternalAssessmentRequest>
t:\ftemp>type plural.xsl 
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="xsd"
                version="2.0">

<xsl:template match="*[ends-with(name(.),'ies')]" priority="1">
  <xsl:element name="{substring(name(.),1,string-length(name(.))-3)}y">
    <xsl:apply-templates select="@*,node()"/>
  </xsl:element>
</xsl:template>

<xsl:template match="*[ends-with(name(.),'s')]">
  <xsl:element name="{substring(name(.),1,string-length(name(.))-1)}">
    <xsl:apply-templates select="@*,node()"/>
  </xsl:element>
</xsl:template>

<xsl:template match="@*|node()"><!--identity for all other nodes-->
  <xsl:copy>
    <xsl:apply-templates select="@*,node()"/>
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>rem Done! 
于 2013-09-19T00:33:13.997 回答
0

s es一个非常通用的 XSLT 1.0 解决方案,它查找以和结尾的元素,ies并通过删除和替换来生成元素名称的sesies版本y

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

<xsl:template match="@*|node()">
  <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="*[substring(local-name(), 
                                 string-length(local-name())) = 's']">   
    <xsl:element name="{substring(name(), 0, string-length(name()))}" 
                 namespace="{namespace-uri()}">
       <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
</xsl:template>

<xsl:template match="*[substring(local-name(), 
                                 string-length(local-name())-1) = 'es']" 
              priority="1">
    <xsl:element name="{substring(name(), 0, string-length(name()))}" 
                 namespace="{namespace-uri()}">
        <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
</xsl:template>

<xsl:template match="*[substring(local-name(), 
                                 string-length(local-name())-2) = 'ies']" 
              priority="2">
    <xsl:element name="{substring(name(), 0, string-length(name())-2)}y" 
                 namespace="{namespace-uri()}">
        <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
</xsl:template>

</xsl:stylesheet>

更具体的样式表将指定您想要更改的每个元素名称,使用|联合运算符匹配其中任何一个,并应用匹配模板中指定的逻辑来删除/更改元素名称的结尾:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">

<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

    <xsl:template match="RequestedLoans | Applicants | Assets | Funds | 
                           Households | Persons | Guarantors | Directors">   
    <xsl:element name="{substring(name(), 0, string-length(name()))}" 
                 namespace="{namespace-uri()}">
       <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
</xsl:template>

<xsl:template match="Incomes | Expenses | Features" priority="1">
    <xsl:element name="{substring(name(), 0, string-length(name()))}" 
                 namespace="{namespace-uri()}">
        <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
</xsl:template>

<xsl:template match="Companies" priority="2">
    <xsl:element name="{substring(name(), 0, string-length(name())-2)}y" 
                 namespace="{namespace-uri()}">
        <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
</xsl:template>

</xsl:stylesheet>
于 2013-09-19T00:41:21.940 回答