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 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 = new java.util.HashSet<String>();
  35. static {
  36. //These are FOP's standard extension properties (fox:*)
  37. PROPERTY_ATTRIBUTES.add("block-progression-unit");
  38. PROPERTY_ATTRIBUTES.add("widow-content-limit");
  39. PROPERTY_ATTRIBUTES.add("orphan-content-limit");
  40. PROPERTY_ATTRIBUTES.add("internal-destination");
  41. PROPERTY_ATTRIBUTES.add("disable-column-balancing");
  42. //These are FOP's extension properties for accessibility
  43. PROPERTY_ATTRIBUTES.add("alt-text");
  44. PROPERTY_ATTRIBUTES.add("header");
  45. //fox:border-*-radius-*
  46. PROPERTY_ATTRIBUTES.add("border-before-radius-start");
  47. PROPERTY_ATTRIBUTES.add("border-before-radius-end");
  48. PROPERTY_ATTRIBUTES.add("border-after-radius-start");
  49. PROPERTY_ATTRIBUTES.add("border-after-radius-end");
  50. PROPERTY_ATTRIBUTES.add("border-start-radius-before");
  51. PROPERTY_ATTRIBUTES.add("border-start-radius-after");
  52. PROPERTY_ATTRIBUTES.add("border-end-radius-before");
  53. PROPERTY_ATTRIBUTES.add("border-end-radius-after");
  54. PROPERTY_ATTRIBUTES.add("border-radius");
  55. PROPERTY_ATTRIBUTES.add("border-before-start-radius");
  56. PROPERTY_ATTRIBUTES.add("border-before-end-radius");
  57. PROPERTY_ATTRIBUTES.add("border-after-start-radius");
  58. PROPERTY_ATTRIBUTES.add("border-after-end-radius");
  59. }
  60. /**
  61. * Constructor.
  62. */
  63. public ExtensionElementMapping() {
  64. namespaceURI = URI;
  65. }
  66. /**
  67. * Initialize the data structures.
  68. */
  69. protected void initialize() {
  70. if (foObjs == null) {
  71. foObjs = new HashMap<String, Maker>();
  72. foObjs.put("outline", new UnknownXMLObj.Maker(URI));
  73. foObjs.put("label", new UnknownXMLObj.Maker(URI));
  74. foObjs.put("destination", new DestinationMaker());
  75. foObjs.put("external-document", new ExternalDocumentMaker());
  76. }
  77. }
  78. static class DestinationMaker extends ElementMapping.Maker {
  79. public FONode make(FONode parent) {
  80. return new Destination(parent);
  81. }
  82. }
  83. static class ExternalDocumentMaker extends ElementMapping.Maker {
  84. public FONode make(FONode parent) {
  85. return new ExternalDocument(parent);
  86. }
  87. }
  88. /** {@inheritDoc} */
  89. public String getStandardPrefix() {
  90. return STANDARD_PREFIX;
  91. }
  92. /** {@inheritDoc} */
  93. public boolean isAttributeProperty(QName attributeName) {
  94. if (!URI.equals(attributeName.getNamespaceURI())) {
  95. throw new IllegalArgumentException("The namespace URIs don't match");
  96. }
  97. return PROPERTY_ATTRIBUTES.contains(attributeName.getLocalName());
  98. }
  99. }