2015-03-08 58 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>

相关问题