XML Schema for layout configurations.
The only changes to the original XML sample: - the root element is called "layout-configs" (plural for container). - the <default> and <config> elements must be defined in that order: - 0..1 of <default> folowed by - 1..n of <config> It's invalid for the <device> node to be empty. default/config are defined by a <xsd:sequence>, which imposes the strict ordering. At first I used an <xsd:choice> which does not impose any ordering but then it becomes possible to define an empty <device> element. I'd rather live with the strict ordering (which also makes sense anyway) and enforce non-empty <device> elements in the schema. BUG 2138329 Change-Id: I581afb1d72825ae79df00d81c74c80a2a18680ad
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.ide.eclipse.adt.internal.sdk;
|
||||
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Public constants for the sdk-repository XML Schema.
|
||||
*/
|
||||
public class LayoutConfigsXsd {
|
||||
|
||||
/** The XML namespace of the layout-configs XML. */
|
||||
public static final String NS_LAYOUT_CONFIG_XSD =
|
||||
"http://schemas.android.com/sdk/android/layout-configs/1"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The "layout-configs" element is the root element of this schema.
|
||||
*
|
||||
* It must contain one or more "device" elements that each define the configurations
|
||||
* available for a given device.
|
||||
*
|
||||
* These definitions are used in the Graphical Layout Editor in the
|
||||
* Android Development Tools (ADT) plugin for Eclipse.
|
||||
*/
|
||||
public static final String NODE_LAYOUT_CONFIGS = "layout-configs"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* A device element must contain at most one "default" element followed
|
||||
* by one or more ""config" elements.
|
||||
*
|
||||
* The "default" element defines all the default parameters inherited
|
||||
* by the following "config" elements. Each "config" element can override
|
||||
* the default values, if any.
|
||||
*
|
||||
* A "device" element also has a required "name" attribute that represents
|
||||
* the user-interface name of this device.
|
||||
*/
|
||||
public static final String NODE_DEVICE = "device"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The "default" element contains zero or more of all the parameter elements
|
||||
* listed below. It defines all the parameters that are common to all
|
||||
* declared "config" elements.
|
||||
*/
|
||||
public static final String NODE_DEFAULT = "default"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The "config" element contains zero or more of all the parameter elements
|
||||
* listed below. The parameters from the "default" element (if present) are
|
||||
* automatically inherited and can be overridden.
|
||||
*/
|
||||
public static final String NODE_CONFIG = "config"; //$NON-NLS-1$
|
||||
|
||||
|
||||
public static final String NODE_SCREEN_SIZE = "screen-size"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_SCREEN_RATIO = "screen-ratio"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_SCREEN_ORIENTATION = "screen-orientation"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_PIXEL_DENSITY = "pixel-density"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_TOUCH_TYPE = "touch-type"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_KEYBOARD_STATE = "keyboard-state"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_TEXT_INPUT_METHOD = "text-input-method"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_NAV_METHOD = "nav-method"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_SCREEN_DIMENSION = "screen-dimension"; //$NON-NLS-1$
|
||||
|
||||
public static final String NODE_SIZE = "size"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The "name" attribute, used by both the "device" and the "config"
|
||||
* elements. It represents the user-interface name of these objects.
|
||||
*/
|
||||
public static final String ATTR_NAME = "name"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Helper to get an input stream of the layout config XML schema.
|
||||
*/
|
||||
public static InputStream getXsdStream() {
|
||||
return LayoutConfigsXsd.class.getResourceAsStream("layout-configs.xsd"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Eclipse Public License, Version 1.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.eclipse.org/org/documents/epl-v10.php
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
-->
|
||||
<xsd:schema
|
||||
targetNamespace="http://schemas.android.com/sdk/android/layout-configs/1"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:c="http://schemas.android.com/sdk/android/layout-configs/1"
|
||||
elementFormDefault="qualified"
|
||||
attributeFormDefault="unqualified"
|
||||
version="1">
|
||||
|
||||
<xsd:element name="layout-configs">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The "layout-configs" element is the root element of this schema.
|
||||
|
||||
It must contain one or more "device" elements that each define the configurations
|
||||
available for a given device.
|
||||
|
||||
These definitions are used in the Graphical Layout Editor in the
|
||||
Android Development Tools (ADT) plugin for Eclipse.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<!-- layout-configs defines a sequence of 1..n device elements. -->
|
||||
<xsd:element name="device" minOccurs="1" maxOccurs="unbounded">
|
||||
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
A device element must contain at most one "default" element
|
||||
followed by one or more "config" elements.
|
||||
|
||||
The "default" element defines all the default parameters
|
||||
inherited by the following "config" elements.
|
||||
Each "config" element can override the default values, if any.
|
||||
|
||||
A "device" element also has a required "name" attribute that
|
||||
represents the user-interface name of this device.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:complexType>
|
||||
<!-- device defines a choice of 0..1 default element
|
||||
and 1..n config elements. -->
|
||||
|
||||
<xsd:sequence>
|
||||
<xsd:element name="default" type="c:parametersType"
|
||||
minOccurs="0" maxOccurs="1" />
|
||||
<xsd:element name="config" type="c:configType"
|
||||
minOccurs="1" maxOccurs="unbounded" />
|
||||
</xsd:sequence>
|
||||
|
||||
<xsd:attribute name="name" type="xsd:normalizedString" use="required" />
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<!-- The type of a device>default element.
|
||||
This is overridden by configType below for the device>config element.
|
||||
-->
|
||||
<xsd:complexType name="parametersType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The parametersType define all the parameters that can happen either in a
|
||||
"default" element or in a named "config" element.
|
||||
Each parameter element can appear once at most.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:all>
|
||||
<!-- parametersType says that 0..1 of each of these elements must be declared. -->
|
||||
|
||||
<xsd:element name="screen-size" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="small" />
|
||||
<xsd:enumeration value="medium" />
|
||||
<xsd:enumeration value="large" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="screen-ratio" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="long" />
|
||||
<xsd:enumeration value="notlong" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="screen-orientation" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="port" />
|
||||
<xsd:enumeration value="land" />
|
||||
<xsd:enumeration value="square" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="pixel-density" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="ldpi" />
|
||||
<xsd:enumeration value="mdpi" />
|
||||
<xsd:enumeration value="hdpi" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="touch-type" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="notouch" />
|
||||
<xsd:enumeration value="stylus" />
|
||||
<xsd:enumeration value="finger" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="keyboard-state" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="keysexposed" />
|
||||
<xsd:enumeration value="keyshidden" />
|
||||
<xsd:enumeration value="keyssoft" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="text-input-method" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="nokeys" />
|
||||
<xsd:enumeration value="qwerty" />
|
||||
<xsd:enumeration value="12key" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="nav-method" minOccurs="0">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:token">
|
||||
<xsd:enumeration value="dpad" />
|
||||
<xsd:enumeration value="trackball" />
|
||||
<xsd:enumeration value="wheel" />
|
||||
<xsd:enumeration value="nonav" />
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="screen-dimension" minOccurs="0">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence minOccurs="2" maxOccurs="2">
|
||||
|
||||
<xsd:element name="size">
|
||||
<xsd:simpleType>
|
||||
<xsd:restriction base="xsd:positiveInteger" />
|
||||
</xsd:simpleType>
|
||||
</xsd:element>
|
||||
|
||||
</xsd:sequence>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:all>
|
||||
</xsd:complexType>
|
||||
|
||||
<!-- The type definition of a device>config element.
|
||||
This type is basically all the element defined by parametersType and an extra
|
||||
required "name" attribute for the user-interface configuration name.
|
||||
-->
|
||||
<xsd:complexType name="configType">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The configType defines the content of a "config" element in a "device" element.
|
||||
|
||||
A "config" element can have all the parameters elements defined by
|
||||
"parameterType". It also has a required "name" attribute that indicates the
|
||||
user-interface name for this configuration.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="c:parametersType">
|
||||
<xsd:attribute name="name" type="xsd:normalizedString" use="required" />
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
||||
</xsd:schema>
|
||||
Reference in New Issue
Block a user