From: Simon Steiner Date: Tue, 10 Jan 2017 10:33:41 +0000 (+0000) Subject: FOP-2362: Using Saxon to intermediate format throws NullPointerException X-Git-Tag: fop-2_2~24 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d2205830cbf59ce090dacfdbae834f8f9a816015;p=xmlgraphics-fop.git FOP-2362: Using Saxon to intermediate format throws NullPointerException git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1778105 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMap.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMap.java index 824ecbabb..56a483ff9 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMap.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPIncludeFormMap.java @@ -68,10 +68,10 @@ public class AFPIncludeFormMap extends AFPExtensionAttachment { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (name != null && name.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name); } if (this.src != null) { - atts.addAttribute(null, ATT_SRC, ATT_SRC, "CDATA", this.src.toASCIIString()); + atts.addAttribute("", ATT_SRC, ATT_SRC, "CDATA", this.src.toASCIIString()); } handler.startElement(CATEGORY, elementName, elementName, atts); handler.endElement(CATEGORY, elementName, elementName); diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java index 83c5325aa..92548246c 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPInvokeMediumMap.java @@ -41,7 +41,7 @@ public class AFPInvokeMediumMap extends AFPExtensionAttachment { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (name != null && name.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name); } handler.startElement(CATEGORY, elementName, elementName, atts); handler.endElement(CATEGORY, elementName, elementName); diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java index 49fdf38ed..7af76b649 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageOverlay.java @@ -89,7 +89,7 @@ public class AFPPageOverlay extends AFPExtensionAttachment { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (name != null && name.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name); } handler.startElement(CATEGORY, elementName, elementName, atts); handler.endElement(CATEGORY, elementName, elementName); diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java index f7379e02c..1925e1456 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSegmentElement.java @@ -117,14 +117,14 @@ public class AFPPageSegmentElement extends AFPPageSetupElement { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (name != null && name.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name); } if (value != null && value.length() > 0) { - atts.addAttribute(null, ATT_VALUE, ATT_VALUE, "CDATA", value); + atts.addAttribute("", ATT_VALUE, ATT_VALUE, "CDATA", value); } if (resourceSrc != null && resourceSrc.length() > 0) { - atts.addAttribute(null, ATT_RESOURCE_SRC, ATT_RESOURCE_SRC, "CDATA", resourceSrc); + atts.addAttribute("", ATT_RESOURCE_SRC, ATT_RESOURCE_SRC, "CDATA", resourceSrc); } handler.startElement(CATEGORY, elementName, elementName, atts); diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java index 12ca5ef38..047d00012 100644 --- a/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java +++ b/fop-core/src/main/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java @@ -138,16 +138,16 @@ public class AFPPageSetup extends AFPExtensionAttachment { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (name != null && name.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name); } if (value != null && value.length() > 0) { - atts.addAttribute(null, ATT_VALUE, ATT_VALUE, "CDATA", value); + atts.addAttribute("", ATT_VALUE, ATT_VALUE, "CDATA", value); } if (this.placement != ExtensionPlacement.DEFAULT) { - atts.addAttribute(null, ATT_PLACEMENT, ATT_PLACEMENT, "CDATA", placement.getXMLValue()); + atts.addAttribute("", ATT_PLACEMENT, ATT_PLACEMENT, "CDATA", placement.getXMLValue()); } if (encoding != TagLogicalElement.State.ENCODING_NONE) { - atts.addAttribute(null, ATT_ENCODING, ATT_ENCODING, "CDATA", String.valueOf(encoding)); + atts.addAttribute("", ATT_ENCODING, ATT_ENCODING, "CDATA", String.valueOf(encoding)); } handler.startElement(CATEGORY, elementName, elementName, atts); if (content != null && content.length() > 0) { diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java index eb8c4bc2f..5ea07b330 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -841,7 +841,7 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler { noteAction(destination.getAction()); AttributesImpl atts = new AttributesImpl(); - atts.addAttribute(null, "name", "name", XMLConstants.CDATA, destination.getName()); + atts.addAttribute("", "name", "name", XMLConstants.CDATA, destination.getName()); try { handler.startElement(DocumentNavigationExtensionConstants.NAMED_DESTINATION, atts); serializeXMLizable(destination.getAction()); @@ -872,8 +872,8 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler { noteAction(bookmark.getAction()); AttributesImpl atts = new AttributesImpl(); - atts.addAttribute(null, "title", "title", XMLUtil.CDATA, bookmark.getTitle()); - atts.addAttribute(null, "starting-state", "starting-state", + atts.addAttribute("", "title", "title", XMLUtil.CDATA, bookmark.getTitle()); + atts.addAttribute("", "starting-state", "starting-state", XMLUtil.CDATA, bookmark.isShown() ? "show" : "hide"); handler.startElement(DocumentNavigationExtensionConstants.BOOKMARK, atts); serializeXMLizable(bookmark.getAction()); @@ -891,7 +891,7 @@ implements IFConstants, IFPainter, IFDocumentNavigationHandler { noteAction(link.getAction()); AttributesImpl atts = new AttributesImpl(); - atts.addAttribute(null, "rect", "rect", + atts.addAttribute("", "rect", "rect", XMLConstants.CDATA, IFUtil.toString(link.getTargetRect())); if (getUserAgent().isAccessibilityEnabled()) { addStructRefAttribute(atts, diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java index 4bd548c73..06dc4a5a7 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/GoToXYAction.java @@ -144,15 +144,15 @@ public class GoToXYAction extends AbstractAction implements DocumentNavigationEx AttributesImpl atts = new AttributesImpl(); if (this.isCompleteExceptTargetLocation()) { final Point reportedTargetLocation = this.getTargetLocation(); - atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); - atts.addAttribute(null, "page-index", "page-index", + atts.addAttribute("", "id", "id", XMLUtil.CDATA, getID()); + atts.addAttribute("", "page-index", "page-index", XMLUtil.CDATA, Integer.toString(pageIndex)); - atts.addAttribute(null, "x", "x", XMLUtil.CDATA, + atts.addAttribute("", "x", "x", XMLUtil.CDATA, Integer.toString(reportedTargetLocation.x)); - atts.addAttribute(null, "y", "y", XMLUtil.CDATA, + atts.addAttribute("", "y", "y", XMLUtil.CDATA, Integer.toString(reportedTargetLocation.y)); } else { - atts.addAttribute(null, "idref", "idref", XMLUtil.CDATA, getID()); + atts.addAttribute("", "idref", "idref", XMLUtil.CDATA, getID()); } handler.startElement(GOTO_XY.getNamespaceURI(), GOTO_XY.getLocalName(), GOTO_XY.getQName(), atts); diff --git a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java index 22e7a270c..45e7563b2 100644 --- a/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java +++ b/fop-core/src/main/java/org/apache/fop/render/intermediate/extensions/URIAction.java @@ -90,11 +90,11 @@ public class URIAction extends AbstractAction implements DocumentNavigationExten public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (hasID()) { - atts.addAttribute(null, "id", "id", XMLUtil.CDATA, getID()); + atts.addAttribute("", "id", "id", XMLUtil.CDATA, getID()); } - atts.addAttribute(null, "uri", "uri", XMLUtil.CDATA, getURI()); + atts.addAttribute("", "uri", "uri", XMLUtil.CDATA, getURI()); if (isNewWindow()) { - atts.addAttribute(null, "show-destination", "show-destination", XMLUtil.CDATA, "new"); + atts.addAttribute("", "show-destination", "show-destination", XMLUtil.CDATA, "new"); } handler.startElement(GOTO_URI.getNamespaceURI(), GOTO_URI.getLocalName(), GOTO_URI.getQName(), atts); diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFDictionaryAttachment.java b/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFDictionaryAttachment.java index 3832619ba..e275bfbdc 100644 --- a/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFDictionaryAttachment.java +++ b/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFDictionaryAttachment.java @@ -113,26 +113,26 @@ public class PDFDictionaryAttachment extends PDFExtensionAttachment { String idName = PDFDictionaryElement.ATT_ID; String id = dictionary.getProperty(PDFDictionaryExtension.PROPERTY_ID); if (id != null) { - attributes.addAttribute(null, idName, idName, "ID", id); + attributes.addAttribute("", idName, idName, "ID", id); } } if (type == PDFDictionaryType.Action) { String actionTypeName = PDFActionElement.ATT_TYPE; String actionType = dictionary.getProperty(PDFActionExtension.PROPERTY_TYPE); if (actionType != null) { - attributes.addAttribute(null, actionTypeName, actionTypeName, "CDATA", actionType); + attributes.addAttribute("", actionTypeName, actionTypeName, "CDATA", actionType); } } else if (type == PDFDictionaryType.Page) { String pageNumbersName = PDFPageExtension.PROPERTY_PAGE_NUMBERS; String pageNumbers = dictionary.getProperty(pageNumbersName); if (pageNumbers != null) { - attributes.addAttribute(null, pageNumbersName, pageNumbersName, "CDATA", pageNumbers); + attributes.addAttribute("", pageNumbersName, pageNumbersName, "CDATA", pageNumbers); } } else if (type == PDFDictionaryType.Dictionary) { String keyName = PDFCollectionEntryElement.ATT_KEY; String key = dictionary.getKey(); if (key != null) { - attributes.addAttribute(null, keyName, keyName, "CDATA", key); + attributes.addAttribute("", keyName, keyName, "CDATA", key); } } return attributes; @@ -142,7 +142,7 @@ public class PDFDictionaryAttachment extends PDFExtensionAttachment { String keyName = PDFCollectionEntryExtension.PROPERTY_KEY; String key = array.getKey(); if (key != null) { - attributes.addAttribute(null, keyName, keyName, "CDATA", key); + attributes.addAttribute("", keyName, keyName, "CDATA", key); } return attributes; } @@ -151,13 +151,13 @@ public class PDFDictionaryAttachment extends PDFExtensionAttachment { String keyName = PDFCollectionEntryElement.ATT_KEY; String key = entry.getKey(); if (key != null) { - attributes.addAttribute(null, keyName, keyName, "CDATA", key); + attributes.addAttribute("", keyName, keyName, "CDATA", key); } if (entry instanceof PDFReferenceExtension) { String refid = ((PDFReferenceExtension) entry).getReferenceId(); if (refid != null) { String refidName = PDFReferenceElement.ATT_REFID; - attributes.addAttribute(null, refidName, refidName, "IDREF", refid); + attributes.addAttribute("", refidName, refidName, "IDREF", refid); } } return attributes; diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileAttachment.java b/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileAttachment.java index 8a6e76ba9..96e429d69 100644 --- a/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileAttachment.java +++ b/fop-core/src/main/java/org/apache/fop/render/pdf/extensions/PDFEmbeddedFileAttachment.java @@ -140,13 +140,13 @@ public class PDFEmbeddedFileAttachment extends PDFExtensionAttachment { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (filename != null && filename.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", filename); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", filename); } if (src != null && src.length() > 0) { - atts.addAttribute(null, ATT_SRC, ATT_SRC, "CDATA", src); + atts.addAttribute("", ATT_SRC, ATT_SRC, "CDATA", src); } if (desc != null && desc.length() > 0) { - atts.addAttribute(null, ATT_DESC, ATT_DESC, "CDATA", desc); + atts.addAttribute("", ATT_DESC, ATT_DESC, "CDATA", desc); } String element = getElement(); handler.startElement(CATEGORY, element, element, atts); diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java b/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java index b463fc3d5..791c793d6 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetPageDevice.java @@ -101,7 +101,7 @@ public class PSSetPageDevice extends PSExtensionAttachment { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (name != null && name.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name); } String element = getElement(); handler.startElement(CATEGORY, element, element, atts); diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetupCode.java b/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetupCode.java index f2d580582..08d3cf485 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetupCode.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/extensions/PSSetupCode.java @@ -90,7 +90,7 @@ public class PSSetupCode extends PSExtensionAttachment { public void toSAX(ContentHandler handler) throws SAXException { AttributesImpl atts = new AttributesImpl(); if (name != null && name.length() > 0) { - atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name); + atts.addAttribute("", ATT_NAME, ATT_NAME, "CDATA", name); } String element = getElement(); handler.startElement(CATEGORY, element, element, atts); diff --git a/fop-core/src/main/java/org/apache/fop/tools/fontlist/FontListSerializer.java b/fop-core/src/main/java/org/apache/fop/tools/fontlist/FontListSerializer.java index 931cf6c28..26f4fadbd 100644 --- a/fop-core/src/main/java/org/apache/fop/tools/fontlist/FontListSerializer.java +++ b/fop-core/src/main/java/org/apache/fop/tools/fontlist/FontListSerializer.java @@ -83,8 +83,8 @@ public class FontListSerializer { continue; } atts.clear(); - atts.addAttribute(null, NAME, NAME, CDATA, familyName); - atts.addAttribute(null, STRIPPED_NAME, STRIPPED_NAME, CDATA, + atts.addAttribute("", NAME, NAME, CDATA, familyName); + atts.addAttribute("", STRIPPED_NAME, STRIPPED_NAME, CDATA, stripQuotes(familyName)); handler.startElement(FAMILY, atts); @@ -109,8 +109,8 @@ public class FontListSerializer { for (Object container : containers) { FontSpec cont = (FontSpec) container; atts.clear(); - atts.addAttribute(null, KEY, KEY, CDATA, cont.getKey()); - atts.addAttribute(null, TYPE, TYPE, CDATA, + atts.addAttribute("", KEY, KEY, CDATA, cont.getKey()); + atts.addAttribute("", TYPE, TYPE, CDATA, cont.getFontMetrics().getFontType().getName()); handler.startElement(FONT, atts); generateXMLForTriplets(handler, cont.getTriplets()); @@ -126,9 +126,9 @@ public class FontListSerializer { for (Object triplet1 : triplets) { FontTriplet triplet = (FontTriplet) triplet1; atts.clear(); - atts.addAttribute(null, NAME, NAME, CDATA, triplet.getName()); - atts.addAttribute(null, STYLE, STYLE, CDATA, triplet.getStyle()); - atts.addAttribute(null, WEIGHT, WEIGHT, CDATA, + atts.addAttribute("", NAME, NAME, CDATA, triplet.getName()); + atts.addAttribute("", STYLE, STYLE, CDATA, triplet.getStyle()); + atts.addAttribute("", WEIGHT, WEIGHT, CDATA, Integer.toString(triplet.getWeight())); handler.element(TRIPLET, atts); }