String value based on pattern : string « XML Schema « XML

XML
1. CSS Style
2. SVG
3. XML Schema
4. XQuery
5. XSLT stylesheet
Java
XML Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
XML » XML Schema » string 
String value based on pattern


File: Data.xml

<?xml version="1.0"?>
<target id="uuid:093a2da1-q345-739r"
        xmlns="http://www.java2java.com"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation=
                          "http://www.java2java.com
                           Schema.xsd">
         <location>
                <latitude>32.904237</latitude>
                <longitude>73.620290</longitude>
                <uncertainty units="meters">2</uncertainty>
        </location>
</target>

File: Schema.xsd

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.java2java.com"
            xmlns:mti="http://www.java2java.com"
            elementFormDefault="qualified">
    <element name="target">
        <complexType>
            <sequence>
                <element name="location" maxOccurs="unbounded">
                    <complexType>
                        <sequence>
                            <element name="latitude" type="mti:latType"/>
                            <element name="longitude" type="mti:lonType"/>
                            <element name="uncertainty" type="mti:uncertaintyType"/>
                        </sequence>
                    </complexType>
                </element>
            </sequence>
            <attribute name="id" type="string" use="required"/>
        </complexType>
    </element>
    <simpleType name="latType">
        <restriction base="string">
            <pattern value="[0-9]\.[0-9]{6}|[1-8][0-9]\.[0-9]{6}|90\.[0-9]{6}|-[0-9]\.[0-9]{6}|-[1-8][0-9]\.[0-9]{6}|-90\.[0-9]{6}"/>
        </restriction>
    </simpleType>
    <simpleType name="lonType">
        <restriction base="string">
            <pattern value="[0-9]\.[0-9]{6}|[1-9][0-9]\.[0-9]{6}|1[0-7][0-9]\.[0-9]{6}|180\.[0-9]{6}|-[0-9]\.[0-9]{6}|-[1-9][0-9]\.[0-9]{6}|-1[0-7][0-9]\.[0-9]{6}|-180\.[0-9]{6}"/>
        </restriction>
    </simpleType>
    <complexType name="uncertaintyType">
        <simpleContent>
            <extension base="nonNegativeInteger">
                <attribute name="units" use="required">
                    <simpleType>
                        <restriction base="string">
                            <enumeration value="meters"/>
                            <enumeration value="feet"/>
                        </restriction>
                    </simpleType>
                </attribute>
            </extension>
        </simpleContent>
    </complexType>
</schema>

 
Related examples in the same category
1. element with type xsd:string
2. restruction based on string type
3. Enumeration of string value
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.