2015-03-08 73 views
-2

我不知道我是否以正確的方式進行操作。但我只是試圖在xml中使用命名空間。當我嘗試將xml轉換爲xsl時出現此錯誤XML Content is not allowed in prologXML內容在序言中是不允許的

這是我的xml

<?xml version="1.0" encoding="UTF-8"?> 
<pi:Payroll_Extract_Employees xmlns:pi="urn:com.sdsd/picof"> 
    <pi:PayGroup> 
    <pi:Header> 
     <pi:Version>19</pi:Version> 
     <pi:Payroll_Company_ID>ADSDP</pi:Payroll_Company_ID> 
     <pi:Payroll_Company_Name>ADSDP</pi:Payroll_Company_Name> 
     <pi:Pay_Group_ID>US1</pi:Pay_Group_ID> 
     <pi:Pay_Group_Name>US1 Salaried</pi:Pay_Group_Name> 
     <pi:Pay_Period_Start>2015-02-01-07:00</pi:Pay_Period_Start> 
     <pi:Pay_Period_End>2015-02-14-07:00</pi:Pay_Period_End> 
     <pi:Updated_From>2015-02-05T06:03:48.000-07:00</pi:Updated_From> 
     <pi:Updated_To>2015-02-06T19:47:39.457-07:00</pi:Updated_To> 
     <pi:All_Effective>false</pi:All_Effective> 
    </pi:Header> 
    </pi:PayGroup> 
</pi:Payroll_Extract_Employees> 

這是我xsl

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xd" xmlns:pi="urn:com.workday/picof"> 

<xsl:template match="/pi:Payroll_Extract_Employees/PayGroup/Header"> 
<folder> 
    <file> 
     <item><xsl:value-of select="Version"/></item> 
     <item><xsl:value-of select="Payroll_Company_ID"/></item> 
    </file> 
    <file> 
     <item><xsl:value-of select="Pay_Group_ID"/></item> 
     <item><xsl:value-of select="Pay_Period_Start"/></item> 
    </file> 
</folder> 
</xsl:template> 

有人能指導我,如果我在一個錯誤的方式做到這一點?

+0

您在此處轉載_不_導致此錯誤的代碼。確保你在編輯器中顯示代碼_exactly_,包括空格。錯誤消息與命名空間無關 - 這是由於XML聲明(禁止)前面的字符。 – 2015-03-08 18:36:10

+0

@MathiasMüller但是,如果我嘗試沒有命名空間,那麼它工作正常。你能用簡單的例子來指導我嗎? – Sridhar 2015-03-08 18:51:43

回答

0

如果你希望你的模板以應用然後確保你使用前綴的所有步驟:

<xsl:template match="/pi:Payroll_Extract_Employees/pi:PayGroup/pi:Header"> <folder> <file> <item><xsl:value-of select="pi:Version"/></item> <item><xsl:value-of select="pi:Payroll_Company_ID"/></item> </file> <file> <item><xsl:value-of select="pi:Pay_Group_ID"/></item> <item><xsl:value-of select="pi:Pay_Period_Start"/></item> </file> </folder> </xsl:template>

相關問題