Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4559

include can't include an HTML file with zhtml

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Major Major
    • 9.5.0
    • 9.0.0, 9.0.1
    • Components, ZHTML
    • Security Level: Jimmy
    • ZK 9.5.0 S1

      Steps to Reproduce

      run the code with zhtml dependency in pom.xml

          <include src="text.html"/>
      

      Current Result

      org.zkoss.zk.ui.UiException: at file:/Users/hawk/Documents/workspace/training/ZK/Module1_Basic/Module1-2/module1_2/src/main/webapp/zul/text.html, line: 1, column: 0
      at org.zkoss.zhtml.impl.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:311)
      at org.zkoss.zhtml.impl.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:293)
      at org.zkoss.zk.ui.metainfo.Parser.parse(Parser.java:121)
      at org.zkoss.zk.ui.metainfo.PageDefinitions$MyLoader.parse(PageDefinitions.java:213)
      at org.zkoss.zk.ui.metainfo.PageDefinitions$MyLoader.parse(PageDefinitions.java:200)
      at org.zkoss.web.util.resource.ResourceLoader.load(ResourceLoader.java:105)
      at org.zkoss.web.util.resource.ResourceLoader.load(ResourceLoader.java:35)
      at org.zkoss.util.resource.ResourceCache$Info.load(ResourceCache.java:227)
      at org.zkoss.util.resource.ResourceCache$Info.<init>(ResourceCache.java:202)
      at org.zkoss.util.resource.ResourceCache.get(ResourceCache.java:134)
      at org.zkoss.web.util.resource.ResourceCaches.get(ResourceCaches.java:123)
      at org.zkoss.zk.ui.metainfo.PageDefinitions.getPageDefinition(PageDefinitions.java:141)
      at org.zkoss.zk.ui.impl.AbstractUiFactory.getPageDefinition(AbstractUiFactory.java:207)
      at org.zkoss.zk.ui.http.ExecutionImpl.getPageDefinition(ExecutionImpl.java:383)
      at org.zkoss.zul.Include.afterCompose(Include.java:509)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:945)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:894)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:781)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:841)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:799)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:745)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:466)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:374)
      at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:215)
      at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:140)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
      at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:533)
      at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:475)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
      at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:514)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:920)
      at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:403)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:184)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:856)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:247)
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:151)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:114)
      at org.eclipse.jetty.server.Server.handle(Server.java:352)
      at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:596)
      at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1049)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:590)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:212)
      at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:426)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:510)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint.access$000(SelectChannelEndPoint.java:34)
      at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:450)
      at java.lang.Thread.run(Thread.java:748)
      Caused by: org.zkoss.zsoup.parser.XHtmlTreeBuilder$ExceptionInfo: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
      at org.zkoss.zsoup.parser.XHtmlTreeBuilder.runParser(XHtmlTreeBuilder.java:39)
      at org.zkoss.zsoup.parser.TreeBuilder.parse(TreeBuilder.java:41)
      at org.zkoss.zsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:55)
      at org.zkoss.zsoup.parser.Parser.parseInput(Parser.java:30)
      at org.zkoss.zsoup.helper.DataUtil.parseByteData(DataUtil.java:115)
      at org.zkoss.zsoup.helper.DataUtil.load(DataUtil.java:63)
      at org.zkoss.zsoup.Zsoup.parse(Zsoup.java:135)
      at org.zkoss.zhtml.impl.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:303)
      ... 50 more
      Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
      at java.util.LinkedList.checkElementIndex(LinkedList.java:555)
      at java.util.LinkedList.get(LinkedList.java:476)
      at org.zkoss.zsoup.parser.HtmlTreeBuilderState$7.process(HtmlTreeBuilderState.java:320)
      at org.zkoss.zsoup.parser.HtmlTreeBuilder.process(HtmlTreeBuilder.java:112)
      at org.zkoss.zsoup.parser.HtmlTreeBuilderState$18.process(HtmlTreeBuilderState.java:1365)
      at org.zkoss.zsoup.parser.HtmlTreeBuilder.process(HtmlTreeBuilder.java:112)
      at org.zkoss.zsoup.parser.TreeBuilder.runParser(TreeBuilder.java:48)
      at org.zkoss.zsoup.parser.XHtmlTreeBuilder.runParser(XHtmlTreeBuilder.java:37)

      Expected Result

      text.html is included correctly

      Debug Information

      • if I remove zhtml from pom.xml, the HTML can be included correctly.
      • could be caused by org.zkoss.zsoup.parser.XHtmlTreeBuilder

      Alternatives

      1. Defer

          <include src="text.html" mode="defer"/>
      

      2. Refined html fragment (head/body should be stripped)

      <div>
      
      <h2>title</h2>
      
      <p>
          some text in an HTML file
      </p>
      </div>
      

      3. include a complete page

      using <iframe/>

            rudyhuang rudyhuang
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 3 days
                3d
                Remaining:
                Time Spent - 2 hours Remaining Estimate - 2 days, 6 hours
                2d 6h
                Logged:
                Time Spent - 2 hours Remaining Estimate - 2 days, 6 hours
                2h