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.attrib;
20
21 import org.apache.ws.commons.schema.XmlSchemaObject;
22 import org.apache.ws.commons.schema.extensions.ExtensionDeserializer;
23 import org.w3c.dom.Attr;
24 import org.w3c.dom.Node;
25
26 import javax.xml.namespace.QName;
27
28 /**
29 * Custom attribute deserializer for our test custom attribute
30 */
31 public class CustomAttributeDeserializer implements ExtensionDeserializer {
32
33 /**
34 * deserialize the given element
35 *
36 * @param schemaObject - Parent schema element
37 * @param name - the QName of the element/attribute to be deserialized.
38 * in the case where a deserializer is used to handle multiple elements/attributes
39 * this may be useful to determine the correct deserialization
40 * @param domNode - the raw DOM Node read from the source. This will be the
41 * extension element itself if for an element or the extension attribute object if
42 * it is an attribute
43 */
44 public void deserialize(XmlSchemaObject schemaObject, QName name, Node domNode) {
45 if (CustomAttribute.CUSTOM_ATTRIBUTE_QNAME.equals(name)){
46 Attr attrib = (Attr)domNode;
47 String value = attrib.getValue();
48 //break the attrib into
49 CustomAttribute customAttrib = new CustomAttribute();
50 String[] strings = value.split(":");
51 customAttrib.setPrefix(strings[0]);
52 customAttrib.setSuffix(strings[1]);
53
54 //put this in the schema object meta info map
55 schemaObject.addMetaInfo(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME,customAttrib);
56 }
57 }
58 }