xref: /trunk/main/ooxml/source/framework/SchemaParser/src/org/apache/openoffice/ooxml/schema/parser/XmlNamespace.java (revision 3309286857f19787ae62bd793a98b5af4edd2ad3)
1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21 
22 package org.apache.openoffice.ooxml.schema.parser;
23 
24 import org.apache.openoffice.ooxml.schema.model.attribute.Attribute;
25 import org.apache.openoffice.ooxml.schema.model.base.Location;
26 import org.apache.openoffice.ooxml.schema.model.base.QualifiedName;
27 import org.apache.openoffice.ooxml.schema.model.schema.SchemaBase;
28 import org.apache.openoffice.ooxml.schema.model.simple.Restriction;
29 import org.apache.openoffice.ooxml.schema.model.simple.SimpleType;
30 
31 /** The http://www.w3.org/XML/1998/namespace namespace is
32  *  implicitly included in all schema files.
33  *
34  *  This class makes the necessary additions to namespace map and Schema object.
35  */
36 public class XmlNamespace
37 {
38     public static final String URI = "http://www.w3.org/XML/1998/namespace";
39     public static final String Prefix = "xml";
40 
Apply(final SchemaBase aSchemaBase)41     public static void Apply (final SchemaBase aSchemaBase)
42     {
43         aSchemaBase.Namespaces.ProvideNamespace(URI, Prefix);
44 
45         final QualifiedName aStSpaceSimpleTypeName = new QualifiedName(URI, Prefix, "ST__space");
46         aSchemaBase.Attributes.Add(
47             new Attribute(
48                 new QualifiedName(URI, Prefix, "space"),
49                 aStSpaceSimpleTypeName,
50                 "optional",
51                 null,
52                 null,
53                 FormDefault.unqualified,
54                 null));
55 
56         final SimpleType aType = new SimpleType(
57             null,
58             aStSpaceSimpleTypeName,
59             new Location());
60         final Restriction aRestriction = new Restriction(
61             aType,
62             new QualifiedName(XsdNamespace.URI, XsdNamespace.Prefix, "token"),
63             null);
64         aRestriction.AddEnumeration("default");
65         aRestriction.AddEnumeration("preserve");
66         aType.AddChild(aRestriction);
67         aSchemaBase.SimpleTypes.Add(aType);
68     }
69 }
70