2011-09-28 41 views
2

我使用FOP(0.95)通过传递使用JAXB(2.2.13)创建的源XML文件来生成文档,当我运行它时,我得到一个几乎为空的PDF(它看起来,如果没有数据源XML提供的,我期望)和唯一的日志输出是:FOP在与JAXB一起使用时无法使用数据

DEBUG [FOP] target-resolution set to: 72.0dpi (px2mm=0.35277778) 
INFO [org.apache.fop.layoutmgr.table.TableLayoutManager] table-layout="fixed" and width="auto", but auto-layout not supported => assuming width="100%" 
WARN [org.apache.fop.layoutmgr.PageBreakingAlgorithm] Part/page 0 overflows the available area in block-progression dimension. (fo:static-content, no context info available) 

但如果我注释掉包信息行

@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.blah.com/ctms/Comparison") 

。 java文件从JAXB从我的XSD生成并重新编译,然后PDF生成罚款。

是否有一个明显的变化,我需要使我可以使用生成的JAXB代码而不编辑任何东西,或者一些调试我可以启用以查看发生了什么?

我的XSD是:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:pi="http://www.blah.com/ctms/Comparison" targetNamespace="http://www.blah.com/ctms/Comparison" elementFormDefault="unqualified"> 
<xs:element name="comparison"> 
    <xs:annotation> 
     <xs:documentation>Document containing comparison data for report</xs:documentation> 
    </xs:annotation> 
    <xs:complexType> 
     <xs:sequence> 
      <xs:element name="sub-category" type="pi:sub-category" minOccurs="0" maxOccurs="unbounded"/> 
      <xs:element name="import-id" type="xs:string"/> 
      <xs:element name="row-no" type="xs:string"/> 
      <xs:element name="investigator-no" type="xs:string"/> 
      <xs:element name="clinical-personnel-name" type="xs:string"/> 
      <xs:element name="report-footer-message" type="xs:string"/> 
      <xs:element name="checklist" type="pi:checklist" minOccurs="0" maxOccurs="unbounded"/> 
    <xs:element name="properties" type="pi:properties" minOccurs="0" maxOccurs="1"/> 
     </xs:sequence> 
    </xs:complexType> 
</xs:element> 
<xs:complexType name="field-type"> 
    <xs:sequence> 
     <xs:element name="importValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> 
     <xs:element name="existingValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> 
    </xs:sequence> 
    <xs:attribute name="name" type="xs:string" use="required"/> 
</xs:complexType> 
<xs:complexType name="record-type"> 
    <xs:sequence> 
     <xs:element name="field" type="pi:field-type" minOccurs="0" maxOccurs="unbounded"/> 
    </xs:sequence> 
</xs:complexType> 
<xs:complexType name="sub-category"> 
    <xs:sequence> 
    <xs:element name="record" type="pi:record-type" minOccurs="0" maxOccurs="unbounded"/> 
    <xs:element name="message" type="xs:string" minOccurs="0" maxOccurs="1"/> 
    </xs:sequence> 
    <xs:attribute name="name" type="xs:string" use="required"/> 
</xs:complexType> 
<xs:complexType name="checklist"> 
    <xs:sequence> 
     <xs:element name="checklist-no" type="xs:string"/> 
     <xs:element name="checklist-title" type="xs:string"/> 
     <xs:element name="checklist-description" type="xs:string"/> 
     <xs:element name="checklist-status" type="xs:string"/> 
     <xs:element name="completed-by" type="xs:string"/> 
     <xs:element name="completed-date" type="xs:string"/> 
     <xs:element name="question-item" type="pi:question-item" maxOccurs="unbounded"/> 
    </xs:sequence> 
</xs:complexType> 
<xs:complexType name="question-item"> 
    <xs:sequence> 
     <xs:element name="item-desc" type="xs:string"/> 
     <xs:element name="response" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> 
     <xs:element name="item-no" type="xs:string"/> 
    </xs:sequence> 
</xs:complexType> 

和下面的是生成的XML的示例:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<ns2:comparison xmlns:ns2="http://www.blah.com/ctms/Comparison"> 
    <sub-category name="Specialist Fields"> 
     <record> 
      <field name="Specialist Field"> 
       <importValue>Adult Endocrinologist [AE]</importValue> 
       <existingValue>Adult Endocrinologist [AE]</existingValue> 
      </field> 
      <field name="Key Opinion Leader"> 
       <importValue></importValue> 
       <existingValue>No</existingValue> 
      </field> 
      <field name="Board Certification"> 
       <importValue></importValue> 
       <existingValue>Yes</existingValue> 
      </field> 
     </record> 
     <record> 
      <field name="Specialist Field"> 
       <importValue>Cardiac Surgeon [CS]</importValue> 
       <existingValue>Cardiac Surgeon [CS]</existingValue> 
      </field> 
      <field name="Key Opinion Leader"> 
       <importValue></importValue> 
       <existingValue>No</existingValue> 
      </field> 
      <field name="Board Certification"> 
       <importValue>No</importValue> 
       <existingValue>Yes</existingValue> 
      </field> 
     </record> 
    </sub-category> 
    <sub-category name="Clinical Personnel Address"> 
     <record> 
      <field> 
       <importValue>2-Line 1</importValue> 
       <importValue>Florida [US-FL]</importValue> 
       <importValue>United States of America [USA]</importValue> 
      </field> 
     </record> 
     <record> 
      <field> 
       <existingValue>Line 1</existingValue> 
       <existingValue>Florida [US-FL]</existingValue> 
       <existingValue>United States of America [USA]</existingValue> 
      </field> 
     </record> 
    </sub-category> 
    <sub-category name="Membership Information"> 
     <record> 
      <field name="Association/Society"> 
       <importValue>The Dennis the Menace Fan Club</importValue> 
      </field> 
      <field> 
       <existingValue>Tufty Club</existingValue> 
      </field> 
     </record> 
    </sub-category> 
    <sub-category name="Centre"> 
     <record> 
      <field name="Centre"> 
       <existingValue>Centre Name 313</existingValue> 
       <existingValue>Address Line 1 for Cneter 313</existingValue> 
       <existingValue>Address Line 2 for Cneter 313</existingValue> 
       <existingValue>Address Line 3 for Cneter 313</existingValue> 
       <existingValue>Address Line 4 for Cneter 313</existingValue> 
       <existingValue>Centre Town City 313</existingValue> 
       <existingValue>P_C 313</existingValue> 
       <existingValue>ZZ Country CA0................ [CA0]</existingValue> 
      </field> 
      <field> 
       <existingValue>Centre Name 312</existingValue> 
       <existingValue>Address Line 1 for Cneter 312</existingValue> 
       <existingValue>Address Line 2 for Cneter 312</existingValue> 
       <existingValue>Address Line 3 for Cneter 312</existingValue> 
       <existingValue>Address Line 4 for Cneter 312</existingValue> 
       <existingValue>Centre Town City 312</existingValue> 
       <existingValue>P_C 312</existingValue> 
       <existingValue>ZZ Country CA0................ [CA0]</existingValue> 
      </field> 
     </record> 
     <message>The system identified 2 Centres as being a potential match to the imported Centre details and therefore both the imported Centre and each Centre associated to the existing Clinical Personnel is listed below.</message> 
    </sub-category> 
    <sub-category name="Clinical Personnel"> 
     <record> 
      <field name="Investigator Alias Code"> 
       <importValue>5656</importValue> 
       <existingValue>545</existingValue> 
      </field> 
      <field name="Title"> 
       <existingValue>Mrs</existingValue> 
      </field> 
     </record> 
    </sub-category> 
    <sub-category name="Therapeutic Interests"> 
     <record> 
      <field name="Therapeutic Group/Interest"> 
       <importValue>Therapeutic Interest Group Descripti Max [ABCDEFZ]/Therapeutic Interest Description 012 Max [ABCDEFZ]</importValue> 
      </field> 
     </record> 
    </sub-category> 
    <sub-category name="Fraud and Misconduct Events"> 
     <record> 
      <field name="Event"> 
       <importValue>Very Bad Things [VBAD]</importValue> 
       <existingValue>Very Bad Things [VBAD]</existingValue> 
      </field> 
      <field name="Event Date"> 
       <importValue>10-Jan-2011</importValue> 
       <existingValue>01-Sep-2011</existingValue> 
      </field> 
     </record> 
     <record> 
      <field name="Event"> 
       <importValue>Bad Things [BAD]</importValue> 
       <existingValue>Bad Things [BAD]</existingValue> 
      </field> 
      <field name="Event Date"> 
       <importValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
       <existingValue>22-Sep-2011</existingValue> 
      </field> 
     </record> 
     <record> 
      <field name="Event"> 
       <existingValue>Extremely Bad Things [EBAD]</existingValue> 
      </field> 
      <field name="Event Date"> 
       <existingValue>14-Sep-2011</existingValue> 
      </field> 
     </record> 
    </sub-category> 
    <import-id>30</import-id> 
    <row-no>2</row-no> 
    <investigator-no>153</investigator-no> 
    <clinical-personnel-name>Mrs B B SPECIALIST</clinical-personnel-name> 
    <report-footer-message>Report Produced at 28-09-2011 09:42 by Mr Installation</report-footer-message> 
    <properties><property key="heading.clinicalPersonnelComparisonReport">Clinical Personnel Comparison Report</property><property key="heading.importId">Import Id</property><property key="heading.recordNo">Record No</property><property key="heading.existingDuplicateClinicalPersonnel">Existing Duplicate Clinical Personnel</property><property key="heading.clinicalPersonnelComparisonReportTitle">This report details the differences which exist between the imported Clinical Personnel and the existing master Clinical Personnel.</property><property key="heading.clinicalPersonnelComparisonReportTitleNoDifferences">No differences exist between the imported Clinical Personnel and the existing master Clinical Personnel.</property><property key="heading.followingClinicalPersonnelDetailsDiffer">The following Clinical Personnel details differ:-</property><property key="heading.clinicalPersonnelDetails">Clinical Personnel Details</property><property key="heading.itemName">Item Name</property><property key="heading.importValue">Import Value</property><property key="heading.existingClinicalPersonnelValue">Existing Clinical Personnel Value</property><property key="heading.addressDetails">Address Details</property><property key="heading.noDifferencesIdentified">No differences identified</property><property key="heading.addressType">Address Type</property><property key="heading.field">Field</property><property key="heading.importAddress">Import Address</property><property key="heading.existingClinicalPersonnelAddress">Existing Clinical Personnel Address</property><property key="heading.fraudMisconduct">Fraud and Misconduct</property><property key="heading.event">Event</property><property key="heading.eventDate">Event Date</property><property key="heading.associatedCentre">Associated Centre</property><property key="heading.importCentre">Import Centre</property><property key="heading.existingClinicalPersonnelCentre">Existing Clinical Personnel Centre</property><property key="heading.specialistsFields">Specialist Fields</property><property key="heading.therapeuticInterests">Therapeutic Interests</property><property key="heading.therapeuticGroupInterest">Therapeutic Group/Interest</property><property key="heading.membershipInformation">Membership Information</property><property key="heading.invMembershipsInformationMembership">Association/Society</property><property key="heading.investigatorNo">Investigator No</property><property key="heading.existingClinicalPersonnelChecklists">Existing Clinical Personnel Checklist(s)</property><property key="heading.checklistNo">Checklist No</property><property key="heading.title">Title</property><property key="heading.description">Description</property><property key="heading.status">Status</property><property key="heading.completedBy">Completed By</property><property key="heading.completedDate">Completed Date</property><property key="heading.question">Question</property><property key="heading.response">Response</property></properties> 
</ns2:comparison> 

(我对上述文件进行的唯一修改是“嗒嗒”来代替我的作品的名字)


更新我也试图在XSD设置elementFormDefault="qualified",但没有帮助(虽然生成的XML确实丢失了“ns2”命名空间前缀)

回答

1

如何创建XSL-FO?一些XSLT转换?看起来像这个转换期望文档在默认名称空间中。

如果是这样,那么有两种方法来计算策略是:

  • 如果你想保持XSLT,因为它是你必须改变模式是namespaceless。
  • 如果您可以更改XSLT,则使其处理名称空间中的元素而不是空名称空间。使用elementFormDefault="qualified"attributeFormDefault="unqualified",这是通常的做法。

决定主要基于这个问题 - 如果你关心你的模式的命名空间。如果你不这样做,第一种方法将花费你更少的努力。我个人而言,我会选择第二个选项,我认为命名空间很重要。

还有一种方法是保留名称空间,但在使用FOP进行渲染之前使用XSLT删除它们。

+0

是的,代码使用XSLT,我很乐意改变它。我会尝试第二种方法。 –

+0

不幸的是,第二种方法并不适合我。最后,我最终删除了命名空间,主要是因为我处于截止日期,而这纯粹是应用程序内部的,所以缺少命名空间并不重要。谢谢 –

相关问题