FOP failing to use data when used with JAXB
I'm generating a document using FOP (0.95) by passing a source XML file created using JAXB (2.2.13), when I run it I get a virtually empty PDF (it looks like I'd expect if no data was supplied in the source XML) and the only log output is:
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)
but if I comment out the line
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.blah.com/ctms/Comparison")
in the package-info.java file generated from my XSD by JAXB and recompile then the PDF generates fine.
Is there an obvious change I need to make so that I can use the generated JAXB code without editing anything, or alternatively some debugging I can enable to see what is happening?
My XSD is:
<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>
and the following is an example of the generated 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>
(The only edit I've made to the above files is to replace my work's name with "blah")
Update I have also tried setting elementFormDefault="qualified"
in the XSD, but that doesn't help (although the generated XML does lose the "ns2" namespace prefix)
How do you create your XSL-FO? Some XSLT transformation? Seems like this transformation expects the document in the default namespace.
If this is so then there's two ways to approch this:
- If you want to keep the XSLT as it is, you have to change the schema to be namespaceless.
- If you're OK to change the XSLT, make it process elements in your namespace instead of empty namespace. Use
elementFormDefault="qualified"
andattributeFormDefault="unqualified"
, it's a usual practice.
The decision is mainly based on the question - if you care about the namespace of your schema. If you don't, the first way will cost you less effort. Me personally, I'd opt for the second option, I think namespaces to be important.
Yet another way is to keep namespaces but use an XSLT to drop them before rendering with FOP.
精彩评论