Sha*_*mmy 3 xml xslt rest sharepoint
我有从对 SharePoint 站点的 REST 调用收到的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xml:base="https://XYZ.net/_api/">
<id>95d0968b-bc93-400d-9bd4-14f8a04f7933</id>
<title />
<updated>2014-05-08T12:30:49Z</updated>
<entry m:etag=""1"">
<id>df1dbe72-22e1-45af-9290-1c6571696169</id>
<category term="SP.Data.XYZABCBudgetLinesListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/FirstUniqueAncestorSecurableObject" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/RoleAssignments" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/AttachmentFiles" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/ContentType" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/FieldValuesAsHtml" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/FieldValuesAsText" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/FieldValuesForEdit" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/File" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/Folder" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(2)/ParentList" />
<title />
<updated>2014-05-08T12:30:49Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
<d:Id m:type="Edm.Int32">2</d:Id>
<d:ContentTypeId>0x009BF34D7FE1615746BB818211276E2E75</d:ContentTypeId>
<d:XYZBudgetLinesIDInXYZABCBudgetLines m:type="Edm.Int32">13154</d:XYZBudgetLinesIDInXYZABCBudgetLines>
<d:XYZIDInXYZABCBudgetLinesId m:type="Edm.Int32">4041</d:XYZIDInXYZABCBudgetLinesId>
<d:XYZABCIDInXYZABCBudgetLinesId m:type="Edm.Int32">3</d:XYZABCIDInXYZABCBudgetLinesId>
<d:ABCIsFromActivatedPAL m:type="Edm.Boolean">false</d:ABCIsFromActivatedPAL>
<d:ABCBudgetCode>16;9030172;10703</d:ABCBudgetCode>
<d:ABCBudgetDonorReportCodeLineNumber m:type="Edm.Double">1</d:ABCBudgetDonorReportCodeLineNumber>
<d:ABCBudgetLineDescription>Thematic - Partner Costs</d:ABCBudgetLineDescription>
<d:ABCTotalEstimatedAmount m:null="true" />
<d:ABCTotalEstimatedAmountToFundingOffice m:type="Edm.Double">0</d:ABCTotalEstimatedAmountToFundingOffice>
<d:ABCTotalEstimatedAmountToAllImplementingOffices m:null="true" />
<d:ABCTotalCommittedAmount m:null="true" />
<d:ABCTotalCommittedAmountToFundingOffice m:type="Edm.Double">0</d:ABCTotalCommittedAmountToFundingOffice>
<d:ABCTotalCommittedAmountToAllImplementingOffices m:null="true" />
<d:ID m:type="Edm.Int32">2</d:ID>
<d:Modified m:type="Edm.DateTime">2014-02-17T12:59:08Z</d:Modified>
<d:Created m:type="Edm.DateTime">2014-02-17T12:59:08Z</d:Created>
<d:AuthorId m:type="Edm.Int32">1028</d:AuthorId>
<d:EditorId m:type="Edm.Int32">1028</d:EditorId>
<d:OData__UIVersionString>1.0</d:OData__UIVersionString>
<d:Attachments m:type="Edm.Boolean">false</d:Attachments>
<d:GUID m:type="Edm.Guid">e5794096-6fc2-48f1-8c8f-0d2fd5244b14</d:GUID>
</m:properties>
</content>
</entry>
<entry m:etag=""1"">
<id>ad8cb0b2-6a8b-4dff-8da4-623527d1034a</id>
<category term="SP.Data.XYZABCBudgetLinesListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/FirstUniqueAncestorSecurableObject" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/RoleAssignments" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/AttachmentFiles" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/ContentType" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/FieldValuesAsHtml" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/FieldValuesAsText" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/FieldValuesForEdit" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/File" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/Folder" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(3)/ParentList" />
<title />
<updated>2014-05-08T12:30:49Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
<d:Id m:type="Edm.Int32">3</d:Id>
<d:ContentTypeId>0x009BF34D7FE1615746BB818211276E2E75</d:ContentTypeId>
<d:XYZBudgetLinesIDInXYZABCBudgetLines m:type="Edm.Int32">13155</d:XYZBudgetLinesIDInXYZABCBudgetLines>
<d:XYZIDInXYZABCBudgetLinesId m:type="Edm.Int32">4041</d:XYZIDInXYZABCBudgetLinesId>
<d:XYZABCIDInXYZABCBudgetLinesId m:type="Edm.Int32">3</d:XYZABCIDInXYZABCBudgetLinesId>
<d:ABCIsFromActivatedPAL m:type="Edm.Boolean">false</d:ABCIsFromActivatedPAL>
<d:ABCBudgetCode>16;9030172;10704</d:ABCBudgetCode>
<d:ABCBudgetDonorReportCodeLineNumber m:type="Edm.Double">2</d:ABCBudgetDonorReportCodeLineNumber>
<d:ABCBudgetLineDescription>Thematic - Direct Implementation</d:ABCBudgetLineDescription>
<d:ABCTotalEstimatedAmount m:null="true" />
<d:ABCTotalEstimatedAmountToFundingOffice m:type="Edm.Double">0</d:ABCTotalEstimatedAmountToFundingOffice>
<d:ABCTotalEstimatedAmountToAllImplementingOffices m:null="true" />
<d:ABCTotalCommittedAmount m:null="true" />
<d:ABCTotalCommittedAmountToFundingOffice m:type="Edm.Double">0</d:ABCTotalCommittedAmountToFundingOffice>
<d:ABCTotalCommittedAmountToAllImplementingOffices m:null="true" />
<d:ID m:type="Edm.Int32">3</d:ID>
<d:Modified m:type="Edm.DateTime">2014-02-17T12:59:08Z</d:Modified>
<d:Created m:type="Edm.DateTime">2014-02-17T12:59:08Z</d:Created>
<d:AuthorId m:type="Edm.Int32">1028</d:AuthorId>
<d:EditorId m:type="Edm.Int32">1028</d:EditorId>
<d:OData__UIVersionString>1.0</d:OData__UIVersionString>
<d:Attachments m:type="Edm.Boolean">false</d:Attachments>
<d:GUID m:type="Edm.Guid">ca568284-a65b-4081-85e5-5c783a51d4f5</d:GUID>
</m:properties>
</content>
</entry>
<entry m:etag=""1"">
<id>f00d3036-ed85-49fd-8838-a20b0eaf7026</id>
<category term="SP.Data.XYZABCBudgetLinesListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/FirstUniqueAncestorSecurableObject" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/RoleAssignments" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/AttachmentFiles" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/ContentType" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/FieldValuesAsHtml" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/FieldValuesAsText" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/FieldValuesForEdit" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/File" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/Folder" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(4)/ParentList" />
<title />
<updated>2014-05-08T12:30:49Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
<d:Id m:type="Edm.Int32">4</d:Id>
<d:ContentTypeId>0x009BF34D7FE1615746BB818211276E2E75</d:ContentTypeId>
<d:XYZBudgetLinesIDInXYZABCBudgetLines m:type="Edm.Int32">13156</d:XYZBudgetLinesIDInXYZABCBudgetLines>
<d:XYZIDInXYZABCBudgetLinesId m:type="Edm.Int32">4041</d:XYZIDInXYZABCBudgetLinesId>
<d:XYZABCIDInXYZABCBudgetLinesId m:type="Edm.Int32">3</d:XYZABCIDInXYZABCBudgetLinesId>
<d:ABCIsFromActivatedPAL m:type="Edm.Boolean">false</d:ABCIsFromActivatedPAL>
<d:ABCBudgetCode>16;9030172;10705</d:ABCBudgetCode>
<d:ABCBudgetDonorReportCodeLineNumber m:type="Edm.Double">3</d:ABCBudgetDonorReportCodeLineNumber>
<d:ABCBudgetLineDescription>Thematic - Partner Capacity Building</d:ABCBudgetLineDescription>
<d:ABCTotalEstimatedAmount m:null="true" />
<d:ABCTotalEstimatedAmountToFundingOffice m:type="Edm.Double">0</d:ABCTotalEstimatedAmountToFundingOffice>
<d:ABCTotalEstimatedAmountToAllImplementingOffices m:null="true" />
<d:ABCTotalCommittedAmount m:null="true" />
<d:ABCTotalCommittedAmountToFundingOffice m:type="Edm.Double">0</d:ABCTotalCommittedAmountToFundingOffice>
<d:ABCTotalCommittedAmountToAllImplementingOffices m:null="true" />
<d:ID m:type="Edm.Int32">4</d:ID>
<d:Modified m:type="Edm.DateTime">2014-02-17T12:59:08Z</d:Modified>
<d:Created m:type="Edm.DateTime">2014-02-17T12:59:08Z</d:Created>
<d:AuthorId m:type="Edm.Int32">1028</d:AuthorId>
<d:EditorId m:type="Edm.Int32">1028</d:EditorId>
<d:OData__UIVersionString>1.0</d:OData__UIVersionString>
<d:Attachments m:type="Edm.Boolean">false</d:Attachments>
<d:GUID m:type="Edm.Guid">afc2ed93-d36c-49d8-912e-8af3bac351af</d:GUID>
</m:properties>
</content>
</entry>
<entry m:etag=""1"">
<id>365f7548-ba26-4363-b6a2-de7ee4bba2d4</id>
<category term="SP.Data.XYZABCBudgetLinesListItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<link rel="edit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/FirstUniqueAncestorSecurableObject" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/RoleAssignments" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/AttachmentFiles" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/ContentType" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/FieldValuesAsHtml" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/FieldValuesAsText" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/FieldValuesForEdit" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/File" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/Folder" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'7f4df39b-61e1-4657-bb81-8211276e2e75')/Items(5)/ParentList" />
<title />
<updated>2014-05-08T12:30:49Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
<d:Id m:type="Edm.Int32">5</d:Id>
<d:ContentTypeId>0x009BF34D7FE1615746BB818211276E2E75</d:ContentTypeId>
<d:XYZBudgetLinesIDInXYZABCBudgetLines m:type="Edm.Int32">13157</d:XYZBudgetLinesIDInXYZABCBudgetLines>
<d:XYZIDInXYZABCBudgetLinesId m:type="Edm.Int32">4041</d:XYZIDInXYZABCBudgetLinesId>
<d:XYZABCIDInXYZABCBudgetLinesId m:type="Edm.Int32">3</d:XYZABCIDInXYZABCBudgetLinesId>
<d:ABCIsFromActivatedPAL m:type="Edm.Boolean">false</d:ABCIsFromActivatedPAL>
<
完成此任务的一个好方法是添加小型的、单一用途的模板。例如
<OriginalID>13154</OriginalID>
Run Code Online (Sandbox Code Playgroud)
将由以下人员创建
<xsl:template match="d:XYZBudgetLinesIDInXYZABCBudgetLines">
<OriginalID><xsl:value-of select="." /></OriginalID>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
为您需要的每个输出元素添加这些模板之一。
现在您需要做的就是创建一个模板来处理atom
输入中的各个元素
<xsl:template match="atom:entry">
<XYZABCBudgetLinesItem>
<xsl:apply-templates select="atom:content/m:properties/*" />
</XYZABCBudgetLinesItem>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
注意:您需要在 XSLT ( xmlns:atom="http://www.w3.org/2005/Atom"
) 中声明原子名称空间前缀,否则模板将不匹配任何内容。作为交换,您可以删除默认名称空间 ( ),因为您对为输出xmlns="http://www.w3.org/2005/Atom"
创建元素并不真正感兴趣。atom
将<xsl:apply-templates select="atom:content/m:properties/*" />
处理 的元数据属性<entry>
,适当地执行您创建的所有小型单一用途模板。
最后应该有一个模板作为起点:
<xsl:template match="/atom:feed">
<XYZABCBudgetLines>
<xsl:apply-templates select="atom:entry" />
</XYZABCBudgetLines>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
最后但并非最不重要的一点是,您应该添加一个通用的空模板来捕获所有未分配任何特定模板的元素:
<xsl:template match="*" />
Run Code Online (Sandbox Code Playgroud)
通过这种方式,您可以抑制您不想在输出中看到的节点。
以下内容将帮助您开始,您可以通过添加更多模板自行完成:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xml:base="https://XYZ.net/_api/"
exclude-result-prefixes="atom m d gml georss"
>
<xsl:template match="/atom:feed">
<XYZABCBudgetLines>
<xsl:apply-templates select="atom:entry" />
</XYZABCBudgetLines>
</xsl:template>
<xsl:template match="atom:entry">
<XYZABCBudgetLinesItem>
<xsl:apply-templates select="atom:content/m:properties/*" />
</XYZABCBudgetLinesItem>
</xsl:template>
<xsl:template match="d:XYZBudgetLinesIDInXYZABCBudgetLines">
<OriginalID><xsl:value-of select="." /></OriginalID>
</xsl:template>
<xsl:template match="*" />
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
哪个会输出
<XYZABCBudgetLines>
<XYZABCBudgetLinesItem>
<OriginalID>13154</OriginalID>
</XYZABCBudgetLinesItem>
<XYZABCBudgetLinesItem>
<OriginalID>13155</OriginalID>
</XYZABCBudgetLinesItem>
<XYZABCBudgetLinesItem>
<OriginalID>13156</OriginalID>
</XYZABCBudgetLinesItem>
<XYZABCBudgetLinesItem>
<OriginalID>13157</OriginalID>
</XYZABCBudgetLinesItem>
<XYZABCBudgetLinesItem>
<OriginalID>13158</OriginalID>
</XYZABCBudgetLinesItem>
</XYZABCBudgetLines>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2803 次 |
最近记录: |