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.

UnknownXMLObj.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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;
  19. import org.xml.sax.Locator;
  20. import org.apache.fop.apps.FOPException;
  21. /**
  22. * Class for handling generic XML from a namespace not recognized by FOP
  23. */
  24. public class UnknownXMLObj extends XMLObj {
  25. private String namespace;
  26. /**
  27. * Inner class for an UnknownXMLObj Maker
  28. */
  29. public static class Maker extends ElementMapping.Maker {
  30. private String space;
  31. /**
  32. * Construct the Maker
  33. * @param ns the namespace for this Maker
  34. */
  35. public Maker(String ns) {
  36. space = ns;
  37. }
  38. /**
  39. * Make an instance
  40. * @param parent FONode that is the parent of the object
  41. * @return the created UnknownXMLObj
  42. */
  43. public FONode make(FONode parent) {
  44. return new UnknownXMLObj(parent, space);
  45. }
  46. }
  47. /**
  48. * Constructs an unknown xml object (called by Maker).
  49. *
  50. * @param parent the parent formatting object
  51. * @param space the namespace for this object
  52. */
  53. protected UnknownXMLObj(FONode parent, String space) {
  54. super(parent);
  55. this.namespace = space;
  56. }
  57. /** {@inheritDoc} */
  58. public String getNamespaceURI() {
  59. return this.namespace;
  60. }
  61. /** {@inheritDoc} */
  62. public String getNormalNamespacePrefix() {
  63. return null; //We don't know that in this case.
  64. }
  65. /** {@inheritDoc} */
  66. protected void addChildNode(FONode child) {
  67. if (doc == null) {
  68. createBasicDocument();
  69. }
  70. super.addChildNode(child);
  71. }
  72. /** {@inheritDoc} */
  73. protected void characters(char[] data, int start, int length,
  74. PropertyList pList, Locator locator) throws FOPException {
  75. if (doc == null) {
  76. createBasicDocument();
  77. }
  78. super.characters(data, start, length, pList, locator);
  79. }
  80. }