Beispiel #1
0
 /**
  * Finds the {@link Maker} used to create {@link FONode} objects of a particular type
  *
  * @param namespaceURI URI for the namespace of the element
  * @param localName name of the Element
  * @return the ElementMapping.Maker that can create an FO object for this element
  * @throws FOPException if a Maker could not be found for a bound namespace.
  */
 private Maker findFOMaker(String namespaceURI, String localName) throws FOPException {
   Maker maker = elementMappingRegistry.findFOMaker(namespaceURI, localName, locator);
   if (maker instanceof UnknownXMLObj.Maker) {
     FOValidationEventProducer eventProducer =
         FOValidationEventProducer.Provider.get(userAgent.getEventBroadcaster());
     eventProducer.unknownFormattingObject(
         this, currentFObj.getName(), new QName(namespaceURI, localName), getEffectiveLocator());
   }
   return maker;
 }
Beispiel #2
0
 /** {@inheritDoc} */
 public void endDocument() throws SAXException {
   this.delegate.endDocument();
   if (this.rootFObj == null && empty) {
     FOValidationEventProducer eventProducer =
         FOValidationEventProducer.Provider.get(userAgent.getEventBroadcaster());
     eventProducer.emptyDocument(this);
   }
   rootFObj = null;
   if (log.isDebugEnabled()) {
     log.debug("Parsing of document complete");
   }
   foEventHandler.endDocument();
 }
Beispiel #3
0
    /** {@inheritDoc} */
    public void startElement(
        String namespaceURI, String localName, String rawName, Attributes attlist)
        throws SAXException {

      /* the node found in the FO document */
      FONode foNode;
      PropertyList propertyList = null;

      // Check to ensure first node encountered is an fo:root
      if (rootFObj == null) {
        empty = false;
        if (!namespaceURI.equals(FOElementMapping.URI) || !localName.equals("root")) {
          FOValidationEventProducer eventProducer =
              FOValidationEventProducer.Provider.get(userAgent.getEventBroadcaster());
          eventProducer.invalidFORoot(
              this, FONode.getNodeString(namespaceURI, localName), getEffectiveLocator());
        }
      } else { // check that incoming node is valid for currentFObj
        if (currentFObj.getNamespaceURI().equals(FOElementMapping.URI)
            || currentFObj.getNamespaceURI().equals(ExtensionElementMapping.URI)) {
          currentFObj.validateChildNode(locator, namespaceURI, localName);
        }
      }

      ElementMapping.Maker fobjMaker = findFOMaker(namespaceURI, localName);

      try {
        foNode = fobjMaker.make(currentFObj);
        if (rootFObj == null) {
          rootFObj = (Root) foNode;
          rootFObj.setBuilderContext(builderContext);
          rootFObj.setFOEventHandler(foEventHandler);
        }
        propertyList = foNode.createPropertyList(currentPropertyList, foEventHandler);
        foNode.processNode(localName, getEffectiveLocator(), attlist, propertyList);
        if (foNode.getNameId() == Constants.FO_MARKER) {
          if (builderContext.inMarker()) {
            nestedMarkerDepth++;
          } else {
            builderContext.switchMarkerContext(true);
          }
        }
        if (foNode.getNameId() == Constants.FO_PAGE_SEQUENCE) {
          builderContext.getXMLWhiteSpaceHandler().reset();
        }
      } catch (IllegalArgumentException e) {
        throw new SAXException(e);
      }

      ContentHandlerFactory chFactory = foNode.getContentHandlerFactory();
      if (chFactory != null) {
        ContentHandler subHandler = chFactory.createContentHandler();
        if (subHandler instanceof ObjectSource && foNode instanceof ObjectBuiltListener) {
          ((ObjectSource) subHandler).setObjectBuiltListener((ObjectBuiltListener) foNode);
        }

        subHandler.startDocument();
        subHandler.startElement(namespaceURI, localName, rawName, attlist);
        depth = 1;
        delegate = subHandler;
      }

      if (currentFObj != null) {
        currentFObj.addChildNode(foNode);
      }

      currentFObj = foNode;
      if (propertyList != null && !builderContext.inMarker()) {
        currentPropertyList = propertyList;
      }

      // fo:characters can potentially be removed during
      // white-space handling.
      // Do not notify the FOEventHandler.
      if (currentFObj.getNameId() != Constants.FO_CHARACTER) {
        currentFObj.startOfNode();
      }
    }