diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2009-10-15 10:47:34 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2009-10-15 10:47:34 +0000 |
commit | a3960ce47f877ae7c9d767dc3804be1bc4ffae24 (patch) | |
tree | 4e56f9a018213cd7fdeb8f98c933bef26445e002 /src/java/org/apache/fop/render/pdf | |
parent | 928e650d8c781448ca2c18cb74908592dcadf0bb (diff) | |
download | xmlgraphics-fop-a3960ce47f877ae7c9d767dc3804be1bc4ffae24.tar.gz xmlgraphics-fop-a3960ce47f877ae7c9d767dc3804be1bc4ffae24.zip |
Made the structure tree processing chain more robust by removing any assumption about prefix names for namespaces.
Avoid warnings issued by reduceFOTree.xsl when FO file contains foreign elements (like MathML).
SimpleStructureTree: replaced XPath query with simple DOM method calls.
Cleaned up, simplified and re-organized reduceFOTree and addPtr stylesheets.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Accessibility@825461 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/pdf')
-rw-r--r-- | src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java index e1f1fae68..2313431f0 100644 --- a/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFLogicalStructureHandler.java @@ -26,6 +26,8 @@ import java.util.Map; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import org.apache.fop.fo.extensions.ExtensionElementMapping; +import org.apache.fop.fo.extensions.InternalElementMapping; import org.apache.fop.pdf.PDFArray; import org.apache.fop.pdf.PDFDictionary; import org.apache.fop.pdf.PDFDocument; @@ -129,22 +131,21 @@ class PDFLogicalStructureHandler { for (int i = 0, n = structureTree.getLength(); i < n; i++) { Node node = structureTree.item(i); - if (node.getNodeName().equals("fo:flow") - || node.getNodeName().equals("fo:static-content")) { - PDFStructElem structElemSect = pdfDoc.getFactory().makeStructureElement( - FOToPDFRoleMap.mapFormattingObject(node.getLocalName(), structElemPart), - structElemPart); - structElemPart.addKid(structElemSect); - NodeList childNodes = node.getChildNodes(); - for (int j = 0, m = childNodes.getLength(); j < m; j++) { - processNode(childNodes.item(j), structElemSect, true); - } + assert node.getLocalName().equals("flow") + || node.getLocalName().equals("static-content"); + PDFStructElem structElemSect = pdfDoc.getFactory().makeStructureElement( + FOToPDFRoleMap.mapFormattingObject(node.getLocalName(), structElemPart), + structElemPart); + structElemPart.addKid(structElemSect); + NodeList childNodes = node.getChildNodes(); + for (int j = 0, m = childNodes.getLength(); j < m; j++) { + processNode(childNodes.item(j), structElemSect, true); } } } private void processNode(Node node, PDFStructElem parent, boolean addKid) { - Node attr = node.getAttributes().getNamedItem("foi:ptr"); + Node attr = node.getAttributes().getNamedItemNS(InternalElementMapping.URI, "ptr"); assert attr != null; String ptr = attr.getNodeValue(); String nodeName = node.getLocalName(); @@ -157,7 +158,8 @@ class PDFLogicalStructureHandler { parent.addKid(structElem); } if (nodeName.equals("external-graphic") || nodeName.equals("instream-foreign-object")) { - Node altTextNode = node.getAttributes().getNamedItem("fox:alt-text"); + Node altTextNode = node.getAttributes().getNamedItemNS( + ExtensionElementMapping.URI, "alt-text"); if (altTextNode != null) { structElem.put("Alt", altTextNode.getNodeValue()); } else { |