我對xsl技術非常陌生。我試圖做的是分裂以下文件:無法使用xsl在springsource中分割xml文件IDE
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<fields>
<fullName>StageName</fullName>
<picklist>
<picklistValues>
<fullName>Prospecting/Needs/Qualification</fullName>
<closed>false</closed>
<default>false</default>
<forecastCategory>Pipeline</forecastCategory>
<probability>25</probability>
<won>false</won>
</picklistValues>
<picklistValues>
<fullName>Proposal/Price Quote</fullName>
<closed>false</closed>
<default>false</default>
<forecastCategory>Pipeline</forecastCategory>
<probability>40</probability>
<won>false</won>
<sorted>false</sorted>
</picklist>
<trackFeedHistory>true</trackFeedHistory>
<trackTrending>false</trackTrending>
<type>Picklist</type>
</fields>
<fields>
<fullName>Status__c</fullName>
<externalId>false</externalId>
<label>Status</label>
<required>false</required>
<trackHistory>false</trackHistory>
<trackTrending>false</trackTrending>
<type>Text</type>
<unique>false</unique>
</fields>
</CustomObject>
到兩個不同的文件,每個場/全名的名字命名 - 後者的元素。所以基本上我想第一個文件:「StageName.xml」:
<fields>
<fullName>StageName</fullName>
<picklist>
<picklistValues>
<fullName>Prospecting/Needs/Qualification</fullName>
<closed>false</closed>
<default>false</default>
<forecastCategory>Pipeline</forecastCategory>
<probability>25</probability>
<won>false</won>
</picklistValues>
<picklistValues>
<fullName>Proposal/Price Quote</fullName>
<closed>false</closed>
<default>false</default>
<forecastCategory>Pipeline</forecastCategory>
<probability>40</probability>
<won>false</won>
<sorted>false</sorted>
</picklist>
<trackFeedHistory>true</trackFeedHistory>
<trackTrending>false</trackTrending>
<type>Picklist</type>
</fields>
和第二個文件:「Status__c.xml」:
<fields>
<fullName>Status__c</fullName>
<externalId>false</externalId>
<label>Status</label>
<required>false</required>
<trackHistory>false</trackHistory>
<trackTrending>false</trackTrending>
<type>Text</type>
<unique>false</unique>
</fields>
我已經寫了下面的小腳本,基於問題 - 答案在計算器:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:redirect="http://xml.apache.org/xalan/redirect"
extension-element-prefixes="redirect">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/root">
<xsl:apply-templates/>
<xsl:for-each select="fields">
<redirect:write file="file_{@id}-output.xml">
<xsl:copy-of select="fields"/>
</redirect:write>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
和我所得到的是下面的唯一文件: 「Opportunity.out.xml」:
<?xml version="1.0" encoding="UTF-8"?>
StageName
Prospecting/Needs/Qualification
false
false
Pipeline
25
false
Proposal/Price Quote
false
false
Pipeline
40
false
false
true
false
Picklist
Status__c
false
Status
false
false
false
Text
false
我正在運行split.xsl文件,通過右鍵單擊 - >運行爲--->在SpringSource中運行XSL轉換。
對於龐大的問題,我很抱歉,但我真的不知道從哪裏開始解決這個問題。
預先感謝您。
你好馬丁,謝謝你的回答。我試過這個解決方案,但我仍然獲得了我發佈的初始輸出。你認爲這可能與springource配置有關嗎? – Antigoni 2014-08-28 08:17:00
@Antigoni,我已經編輯了答案,並修正了一個匹配模式,以便與您提供的樣本一起工作(這也需要進行更正以使其成形良好)。 – 2014-08-28 09:13:04
好的@Martin,再次感謝。最後兩個簡單問題:我如何檢查我的Xalan版本,以及2.您在命令行輸入什麼命令以從那裏運行它?再次感謝您的幫助。 – Antigoni 2014-08-28 12:55:38