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