AH Formatter / XSL Formatter
Q&A



XSLT/XSL-FO/MathML Technics

Entity

Top
Basic, General
About AH Formatter
About XSL Formatter
Operation
Programming
XSLT/XSL-FO/SVG/MathML Conformance
XSLT/XSL-FO/MathML Technics
Index
Q.  When I tried to embed an external file (external entity) in my FO using entity reference, it was not reflected in a formatted result. Why not? [No.2002111502]
A. 

This phenomenon occurs because MSXML is used as a parser. The following shows the example:

[file name:test.fo]

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root [ <!ENTITY testseg SYSTEM "testseg.fo"> ]>
<root xmlns="http://www.w3.org/1999/XSL/Format" >
  <layout-master-set>
    <simple-page-master master-name="frame">
      <region-body region-name="frame-body"/>
    </simple-page-master>
  </layout-master-set>

  <page-sequence master-reference="frame">
    <flow flow-name="frame-body">
      &testseg;
    </flow>
  </page-sequence>
</root>

[file name:testseg.fo]

<block>
    This is a test
</block>

When there is no namespace for each entity, MSXML identifies it as null namespace, not to be FO Object. As a result, XSL Formatter cannot display the content.

That is, the namespace of the block in the external entity (testseg.fo) doesn't change to the namespace specified in the document entity (test.fo).

Therefore it is expanded as follows.

[file name:test.fo (after expansion)]

<?xml version="1.0" encoding="utf-8"?>
<root xmlns="http://www.w3.org/1999/XSL/Format" >
  <layout-master-set>
    <simple-page-master master-name="frame">
      <region-body region-name="frame-body"/>
    </simple-page-master>
  </layout-master-set>

  <page-sequence master-reference="frame">
    <flow flow-name="frame-body">
      <block xmlns="">This is a test</block>
    </flow>
  </page-sequence>
</root>

Entity name &testseg; is expanded as <block xmlns="">This is a test</block>. As xmlns="" is no a FO namespace, XSL Formatter ignores it and doesn't process it. That's why it was not reflected in a formatted result.

In order to avoid this, declare FO namespace to the block in the external entity (testseg.fo), too.

[file name:testseg.fo (after modified)]

<block xmlns="http://www.w3.org/1999/XSL/Format">
    This is a test
</block>

Copyright © 1999-2011 Antenna House, Inc. All rights reserved.
Antenna House is a trademark of Antenna House, Inc.