2016-08-04 57 views
0

我在寫一個XSLT並在java中運行它。我正在使用Saxon。當我運行我的程序時,我得到了下面的異常。xslt在輸出方法創建時出現混亂

Error at xsl:value-of on line 314 of chapters.xsl: 
    SERE0014: Illegal HTML character: decimal 157 
    at xsl:call-template name="entry" (file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl#417) 
    in built-in template rule 
    at xsl:apply-templates (file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl#385) 
    processing /chapter/section[1]/section[5]/table[1]/tgroup[1]/tbody[1] 
    at xsl:apply-templates (file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl#370) 
    processing /chapter/section[1]/section[5]/table[1]/tgroup[1] 
    at xsl:apply-templates (file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl#205) 
    processing /chapter/section[1]/section[5]/table[1] 
    at xsl:apply-templates (file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl#205) 
    processing /chapter/section[1]/section[5] 
    at xsl:apply-templates (file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl#61) 
    processing /chapter/section[1] 
    at xsl:apply-templates (file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl#19) 
    processing /chapter 
; SystemID: file:///C:/Users/u0138039/Desktop/Proview/HK/2016/COMPORD/final/XSLT/chapters.xsl; Line#: 314; Column#: -1 
net.sf.saxon.trans.XPathException: Illegal HTML character: decimal 157 
    at net.sf.saxon.serialize.HTMLEmitter.writeEscape(HTMLEmitter.java:366) 
    at net.sf.saxon.serialize.XMLEmitter.characters(XMLEmitter.java:594) 
    at net.sf.saxon.serialize.HTMLEmitter.characters(HTMLEmitter.java:428) 
    at net.sf.saxon.serialize.HTMLIndenter.characters(HTMLIndenter.java:255) 
    at net.sf.saxon.event.ProxyReceiver.characters(ProxyReceiver.java:194) 
    at net.sf.saxon.event.ProxyReceiver.characters(ProxyReceiver.java:194) 
    at net.sf.saxon.event.ProxyReceiver.characters(ProxyReceiver.java:194) 
    at net.sf.saxon.event.ProxyReceiver.characters(ProxyReceiver.java:194) 
    at net.sf.saxon.event.ComplexContentOutputter.characters(ComplexContentOutputter.java:174) 
    at net.sf.saxon.expr.instruct.ValueOf.processValue(ValueOf.java:295) 
    at net.sf.saxon.expr.instruct.SimpleNodeConstructor.processLeavingTail(SimpleNodeConstructor.java:222) 
    at net.sf.saxon.expr.instruct.ValueOf.processLeavingTail(ValueOf.java:280) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.AnalyzeString.processLeavingTail(AnalyzeString.java:443) 
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:336) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1124) 
    at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:516) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1061) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:284) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:244) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Template.expand(Template.java:367) 
    at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:343) 
    at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:419) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:336) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1124) 
    at net.sf.saxon.trans.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:65) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1100) 
    at net.sf.saxon.expr.instruct.ApplyTemplates$ApplyTemplatesPackage.processLeavingTail(ApplyTemplates.java:516) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1061) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:284) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:244) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:336) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1124) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:284) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:244) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:336) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1124) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:284) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:244) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:336) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1124) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:284) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:244) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:336) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1124) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:284) 
    at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:244) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:144) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:450) 
    at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:389) 
    at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:669) 
    at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:336) 
    at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1124) 
    at net.sf.saxon.Controller.transformDocument(Controller.java:2106) 
    at net.sf.saxon.Controller.transform(Controller.java:1705) 
    at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:547) 
    at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:177) 
    at com.s1a.alpha.APP2.main(APP2.java:74) 

而且我已經改變了我的輸出methon到xml,它最初是html。令我驚訝的是,沒有異常,並生成文件。我很好奇,想知道如何和爲什麼這個失敗html和成功與xml

感謝

+0

您可以顯示錯誤來源的'xsl:on line 314'值嗎?謝謝! –

+0

@TimC'\t的 \t \t \t \t \t的 \t \t \t \t'中這塊我已經''in line 314 – user3872094

回答

0

https://www.w3.org/TR/xslt-xquery-serialization/#html-output,它需要

某些字符,特別是控制字符#x7F-#x9F ,在XML中爲 合法,但不在HTML中。當數據模型的實例中出現這種字符 時,這是一個序列化錯誤 [err:SERE0014]以使用HTML輸出方法。串行器必須發出信號 錯誤。

十進制157是十六進制9D,所以它在這個範圍內。

0

當x80-x9f範圍內的字符出現在您的輸入中時,通常意味着該文件採用Windows-1252編碼,但被錯誤標記爲ISO-8859-1。不過,我有點驚訝地發現x9D造成了麻煩,因爲這在Windows-1252中是未分配的。你認爲它應該是什麼性格?

請注意,如果您指定HTML版本5.0作爲輸出方法,那麼@MartinHonnen引用的規則對於XSLT 3.0是寬鬆的。但是,如果包含此類字符的輸入有問題,則不會改變這一事實。

還要注意,這個範圍內的字符在XML 1.0中是不允許的,但是它們在XML 1.1中是允許的。你沒有給我們足夠的信息來看看這個流氓角色如何進入系統。

+0

Hi @Michael Kay,我將HTML版本更改爲5.0,它工作正常。但是我很想知道後端發生了什麼。 – user3872094