1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package tests.customext.elt;
20
21 import org.apache.ws.commons.schema.XmlSchemaObject;
22 import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
23 import org.w3c.dom.Element;
24 import org.w3c.dom.Node;
25
26 import javax.xml.namespace.QName;
27
28 /**
29 * Custom element deserializer
30 */
31 public class CustomElementDeserializer implements ExtensionDeserializer {
32 /**
33 * deserialize the given element
34 *
35 * @param schemaObject - Parent schema element
36 * @param name - the QName of the element/attribute to be deserialized.
37 * in the case where a deserializer is used to handle multiple elements/attributes
38 * this may be useful to determine the correct deserialization
39 * @param domNode - the raw DOM Node read from the source. This will be the
40 * extension element itself if for an element or the extension attribute object if
41 * it is an attribute
42 */
43 public void deserialize(XmlSchemaObject schemaObject, QName name, Node domNode) {
44 if (CustomElement.CUSTOM_ELT_QNAME.equals(name)){
45 Element elt = (Element)domNode;
46
47 CustomElement customElement = new CustomElement();
48 customElement.setPrefix(elt.getAttribute("prefix"));
49 customElement.setSuffix(elt.getAttribute("suffix"));
50
51 //put this in the schema object meta info map
52 schemaObject.addMetaInfo(CustomElement.CUSTOM_ELT_QNAME,customElement);
53 }
54 }
55 }