You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ExtensionElementMapping.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fo.extensions;
  19. import java.util.HashMap;
  20. import java.util.Set;
  21. import org.apache.xmlgraphics.util.QName;
  22. import org.apache.fop.fo.ElementMapping;
  23. import org.apache.fop.fo.FONode;
  24. import org.apache.fop.fo.UnknownXMLObj;
  25. import org.apache.fop.fo.extensions.destination.Destination;
  26. /**
  27. * Element mapping for FOP's proprietary extension to XSL-FO.
  28. */
  29. public class ExtensionElementMapping extends ElementMapping {
  30. /** The FOP extension namespace URI */
  31. public static final String URI = "http://xmlgraphics.apache.org/fop/extensions";
  32. /** The standard XML prefix for elements and attributes in this namespace. */
  33. public static final String STANDARD_PREFIX = "fox";
  34. private static final Set<String> PROPERTY_ATTRIBUTES
  35. = new java.util.HashSet<String>();
  36. static {
  37. //These are FOP's standard extension properties (fox:*)
  38. PROPERTY_ATTRIBUTES.add("block-progression-unit");
  39. PROPERTY_ATTRIBUTES.add("widow-content-limit");
  40. PROPERTY_ATTRIBUTES.add("orphan-content-limit");
  41. PROPERTY_ATTRIBUTES.add("internal-destination");
  42. PROPERTY_ATTRIBUTES.add("disable-column-balancing");
  43. //These are FOP's extension properties for accessibility
  44. PROPERTY_ATTRIBUTES.add("alt-text");
  45. }
  46. /**
  47. * Constructor.
  48. */
  49. public ExtensionElementMapping() {
  50. namespaceURI = URI;
  51. }
  52. /**
  53. * Initialize the data structures.
  54. */
  55. protected void initialize() {
  56. if (foObjs == null) {
  57. foObjs = new HashMap<String, Maker>();
  58. foObjs.put("outline", new UnknownXMLObj.Maker(URI));
  59. foObjs.put("label", new UnknownXMLObj.Maker(URI));
  60. foObjs.put("destination", new DestinationMaker());
  61. foObjs.put("external-document", new ExternalDocumentMaker());
  62. }
  63. }
  64. static class DestinationMaker extends ElementMapping.Maker {
  65. public FONode make(FONode parent) {
  66. return new Destination(parent);
  67. }
  68. }
  69. static class ExternalDocumentMaker extends ElementMapping.Maker {
  70. public FONode make(FONode parent) {
  71. return new ExternalDocument(parent);
  72. }
  73. }
  74. /** {@inheritDoc} */
  75. public String getStandardPrefix() {
  76. return STANDARD_PREFIX;
  77. }
  78. /** {@inheritDoc} */
  79. public boolean isAttributeProperty(QName attributeName) {
  80. if (!URI.equals(attributeName.getNamespaceURI())) {
  81. throw new IllegalArgumentException("The namespace URIs don't match");
  82. }
  83. return PROPERTY_ATTRIBUTES.contains(attributeName.getLocalName());
  84. }
  85. }