325N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 325N/A * This code is free software; you can redistribute it and/or modify it 325N/A * under the terms of the GNU General Public License version 2 only, as 325N/A * published by the Free Software Foundation. Oracle designates this 325N/A * particular file as subject to the "Classpath" exception as provided 325N/A * by Oracle in the LICENSE file that accompanied this code. 325N/A * This code is distributed in the hope that it will be useful, but WITHOUT 325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 325N/A * version 2 for more details (a copy is included in the LICENSE file that 325N/A * accompanied this code). 325N/A * You should have received a copy of the GNU General Public License version 325N/A * 2 along with this work; if not, write to the Free Software Foundation, 325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 325N/A * or visit www.oracle.com if you need additional information or have any 325N/A * Internalizes external binding declarations. 325N/A * The {@link #transform(DOMForest,boolean)} method is the entry point. 325N/A * Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com) 325N/A * Internalize all <jaxb:bindings> customizations in the given forest. 325N/A * if the SCD support is enabled, the return bindings need to be applied 325N/A * after schema components are parsed. 325N/A * If disabled, the returned binding set will be empty. 325N/A * SCDs are only for XML Schema, and doesn't make any sense for other 325N/A * DOMForest object currently being processed. 325N/A * All errors found during the transformation is sent to this object. 325N/A * If true, the SCD-based target selection is supported. 325N/A // either target nodes are conventional DOM nodes (as per spec), 325N/A // ... or it will be schema components by means of SCD (RI extension) 325N/A // identify target nodes for all <jaxb:bindings> 325N/A // initially, the inherited context is itself 325N/A // then move them to their respective positions. 325N/A * Validates attributes of a <jaxb:bindings> element. 325N/A continue;
// all foreign namespace OK. 325N/A // TODO: flag error for this undefined attribute 325N/A * Determines the target node of the "bindings" element 325N/A * by using the inherited target node, then put 325N/A * the result into the "result" map and the "scd" map. 325N/A * @param inheritedTarget 325N/A * The current target node. This always exists, even if 325N/A * the user starts specifying targets via SCD (in that case 325N/A * this inherited target is just not going to be used.) 325N/A * If the ancestor <bindings> node specifies @scd to 325N/A * specify the target via SCD, then this parameter represents that context. 325N/A // start by the inherited target 325N/A // look for @schemaLocation 325N/A // enhancement - schemaLocation="*" = bind to all schemas.. 325N/A // TODO: use the URI class 325N/A // TODO: honor xml:base 325N/A return;
// abort processing this <jaxb:bindings> 325N/A return;
// abort processing this <jaxb:bindings> 325N/A // SCD selector was found, but it's not activated. report an error 325N/A // but recover by handling it anyway. this also avoids repeated error messages. 325N/A return;
// abort processing this bindings 325N/A // update the result map 325N/A // look for child <jaxb:bindings> and process them recursively 325N/A * Moves JAXB customizations under their respective target nodes. 325N/A if (
target ==
null)
// this must be the result of an error on the external binding. 325N/A // recover from the error by ignoring this node 325N/A // process child <jaxb:bindings> recursively 325N/A // <jaxb:globalBindings> always go to the root of document. 325N/A // move this node under the target 325N/A * Moves the "decl" node under the "target" node. 325N/A * A JAXB customization element (e.g., <jaxb:class>) 325N/A * XML Schema element under which the declaration should move. 325N/A * For example, <xs:element> 325N/A // copy in-scope namespace declarations of the decl node 325N/A // to the decl node itself so that this move won't change 325N/A // the in-scope namespace bindings. 325N/A // if this is the first time we see this namespace bindings, 325N/A // copy the declaration. 325N/A // if p==decl, there's no need to. Note that 325N/A // we want to add prefix to inscopes even if p==Decl 325N/A // if the default namespace was undeclared in the context of decl, 325N/A // it must be explicitly set to "" since the new environment might 325N/A // have a different default namespace URI. 325N/A // finally move the declaration to the target node. 325N/A // if they belong to different DOM documents, we need to clone them 325N/A // this effectively clones a ndoe,, so we need to copy locators. 325N/A * Recursively visits sub-elements and declare all used namespaces. 325N/A * TODO: the fact that we recognize all namespaces in the extension 325N/A // if this comes from external namespaces, add the namespace to 325N/A // @extensionBindingPrefixes. 325N/A * Adds the specified namespace URI to the jaxb:extensionBindingPrefixes 325N/A * attribute of the target document. 325N/A // look for the attribute 325N/A // no such attribute. Create one. 325N/A // avoid redeclaring the same namespace twice. 325N/A * Declares a new prefix on the given element and associates it 325N/A * with the specified namespace URI. 325N/A * Note that this method doesn't use the default namespace 325N/A // look for existing namespaces. 325N/A // none found. allocate new. 325N/A continue;
// this prefix is already allocated. 325N/A * Copies location information attached to the "src" node to the "dst" node. 325N/A // recursively process child elements