001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id: Destination.java 525526 2007-04-04 15:05:30Z jeremias $ */
019:
020: package org.apache.fop.fo.extensions.destination;
021:
022: import org.apache.fop.fo.ValidationException;
023: import org.apache.fop.apps.FOPException;
024: import org.apache.fop.fo.PropertyList;
025: import org.apache.fop.fo.FONode;
026: import org.apache.fop.fo.pagination.Root;
027: import org.apache.fop.fo.extensions.ExtensionElementMapping;
028:
029: import org.xml.sax.Attributes;
030: import org.xml.sax.Locator;
031:
032: /**
033: * Class for named destinations in PDF.
034: */
035: public class Destination extends FONode {
036:
037: private String internalDestination;
038: private Root root;
039:
040: /**
041: * Constructs a Destination object (called by Maker).
042: *
043: * @param parent the parent formatting object
044: */
045: public Destination(FONode parent) {
046: super (parent);
047: root = parent.getRoot();
048: }
049:
050: /**
051: * @see org.apache.fop.fo.FONode#processNode(java.lang.String, org.xml.sax.Locator,
052: * org.xml.sax.Attributes, org.apache.fop.fo.PropertyList)
053: */
054: public void processNode(String elementName, Locator locator,
055: Attributes attlist, PropertyList pList) throws FOPException {
056: internalDestination = attlist.getValue("internal-destination");
057: if (internalDestination == null
058: || internalDestination.length() == 0) {
059: attributeError("Missing attribute: internal-destination must be specified.");
060: }
061: }
062:
063: /**
064: * @see org.apache.fop.fo.FONode#endOfNode
065: */
066: protected void endOfNode() throws FOPException {
067: root.addDestination(this );
068: }
069:
070: /**
071: * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
072: XSL/FOP: empty
073: */
074: protected void validateChildNode(Locator loc, String nsURI,
075: String localName) throws ValidationException {
076: invalidChildError(loc, nsURI, localName);
077: }
078:
079: /**
080: * Returns the internal destination (an reference of the id property of any FO).
081: * @return the internal destination
082: */
083: public String getInternalDestination() {
084: return internalDestination;
085: }
086:
087: /** @see org.apache.fop.fo.FONode#getNamespaceURI() */
088: public String getNamespaceURI() {
089: return ExtensionElementMapping.URI;
090: }
091:
092: /** @see org.apache.fop.fo.FONode#getNormalNamespacePrefix() */
093: public String getNormalNamespacePrefix() {
094: return "fox";
095: }
096:
097: /** @see org.apache.fop.fo.FONode#getLocalName() */
098: public String getLocalName() {
099: return "destination";
100: }
101:
102: }
|