--- /dev/null
+package org.apache.fop.fo.extensions.destination;\r
+\r
+import org.apache.fop.fo.ValidationException;\r
+import org.apache.fop.apps.FOPException;\r
+import org.apache.fop.fo.PropertyList;\r
+import org.apache.fop.fo.FOEventHandler;\r
+import org.apache.fop.fo.FONode;\r
+import org.apache.fop.fo.FObj;\r
+import org.apache.fop.fo.pagination.Root;\r
+import org.apache.fop.fo.extensions.ExtensionElementMapping;\r
+\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.Locator;\r
+\r
+/**\r
+ * Class for named destinations in PDF.\r
+ */\r
+public class Destination extends FObj {\r
+\r
+ String internalDestination;\r
+ Root root;\r
+\r
+ /**\r
+ * Constructs a Destination object (called by Maker).\r
+ *\r
+ * @param parent the parent formatting object\r
+ */\r
+ public Destination(FONode parent) {\r
+ super(parent);\r
+ root = parent.getRoot();\r
+ }\r
+\r
+ /**\r
+ * @see org.apache.fop.fo.FObj#bind(PropertyList)\r
+ */\r
+ public void bind(PropertyList pList) throws FOPException {\r
+ internalDestination = pList.get(PR_INTERNAL_DESTINATION).getString();\r
+ if (internalDestination.length() == 0) {\r
+ attributeError("Missing attribute: internal-destination must be specified.");\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @see org.apache.fop.fo.FONode#endOfNode\r
+ */\r
+ protected void endOfNode() throws FOPException {\r
+ root.addDestination(this);\r
+ }\r
+\r
+ /**\r
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)\r
+ XSL/FOP: empty\r
+ */\r
+ protected void validateChildNode(Locator loc, String nsURI, String localName)\r
+ throws ValidationException {\r
+ invalidChildError(loc, nsURI, localName);\r
+ }\r
+\r
+ public String getInternalDestination() {\r
+ return internalDestination;\r
+ }\r
+\r
+ /** @see org.apache.fop.fo.FONode#getNamespaceURI() */\r
+ public String getNamespaceURI() {\r
+ return ExtensionElementMapping.URI;\r
+ }\r
+\r
+ /** @see org.apache.fop.fo.FONode#getNormalNamespacePrefix() */\r
+ public String getNormalNamespacePrefix() {\r
+ return "fox";\r
+ }\r
+\r
+ /** @see org.apache.fop.fo.FONode#getLocalName() */\r
+ public String getLocalName() {\r
+ return "destination";\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+package org.apache.fop.fo.extensions.destination;\r
+\r
+import java.util.HashMap;\r
+import java.util.Set;\r
+\r
+import org.apache.fop.fo.FONode;\r
+import org.apache.fop.fo.ElementMapping;\r
+import org.apache.fop.fo.extensions.ExtensionElementMapping;\r
+import org.apache.fop.util.QName;\r
+\r
+import org.apache.fop.fo.extensions.destination.Destination;\r
+\r
+/**\r
+ * Set up the destination element mapping.\r
+ */\r
+public class DestinationElementMapping extends ElementMapping {\r
+ \r
+ /**\r
+ * The FOP extension namespace URI\r
+ */\r
+ public static final String URI = ExtensionElementMapping.URI;\r
+\r
+ private static final Set propertyAttributes = new java.util.HashSet();\r
+ \r
+ static {\r
+ //The extension property (fox:*) for named destinations\r
+ propertyAttributes.add("internal-destination");\r
+ }\r
+\r
+ /**\r
+ * Constructor.\r
+ */\r
+ public DestinationElementMapping() {\r
+ namespaceURI = URI;\r
+ }\r
+\r
+ /**\r
+ * @see org.apache.fop.fo.ElementMapping#initialize()\r
+ */\r
+ protected void initialize() {\r
+ if (foObjs == null) {\r
+ foObjs = new HashMap();\r
+ foObjs.put("destination", new DestinationMaker());\r
+ }\r
+ }\r
+\r
+ static class DestinationMaker extends ElementMapping.Maker {\r
+ public FONode make(FONode parent) {\r
+ return new Destination(parent);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * @see org.apache.fop.fo.ElementMapping#getStandardPrefix()\r
+ */\r
+ public String getStandardPrefix() {\r
+ return "fox";\r
+ }\r
+ \r
+ /**\r
+ * @see org.apache.fop.fo.ElementMapping#isAttributeProperty(org.apache.fop.util.QName)\r
+ */\r
+ public boolean isAttributeProperty(QName attributeName) {\r
+ if (!URI.equals(attributeName.getNamespaceURI())) {\r
+ throw new IllegalArgumentException("The namespace URIs don't match");\r
+ }\r
+ return propertyAttributes.contains(attributeName.getLocalName());\r
+ }\r
+ \r
+}\r
--- /dev/null
+<!--\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+-->\r
+<HTML>\r
+<TITLE>org.apache.fop.destination Package</TITLE>\r
+<BODY>\r
+<P>Classes to support named destinations (only relevant for PDF output)</P>\r
+</BODY>\r
+</HTML>
\ No newline at end of file