私は次のXMLを持っています
<ExternalAssessmentRequest>
</ExternalAssessmentRequest>
誰かが私を助けることができれば、本当にありがとう。よろしく
これは、自分で入力できるルックアップ テーブルを使用したソリューションです。
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 に感謝します。
他の回答で説明されている名前空間の問題に対処していない、回答の 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!
あなたはすでに試したことを示していません。繰り返しになりますが、あなたが私たちに指導を求めているのか、それともあなたのために仕事をするよう求めているのかはわかりません.
以下の例では、複数形に関して次の仮定をしています。複数形がある場合は、あなた次第です。
対応したい「複数から単一へ」のルールをすべて列挙しておけば、役に立ちました。たとえば、という名前の要素がある場合、<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!
s
es
andで終わる要素を検索し、 を削除して に置き換えることでies
、要素名の単数バージョンを生成する、非常に一般的な XSLT 1.0 ソリューションです。s
es
ies
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>