2011-09-28 83 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

不幸的是,第二種方法並不適合我。最後,我最終刪除了命名空間,主要是因爲我處於截止日期,而這純粹是應用程序內部的,所以缺少命名空間並不重要。謝謝 –

相關問題