473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

question about attributes

Suppose I want to specify a position on the earth. I could define an
element such as

<position coords="WGS84", lat="34.56223", lon="-121.8277"/>

where lat and lon are latitude and longitude in the WGS84 coordinate
system. Now suppose I also want to have the option of specifying the
position in another coordinate system, a locally level cartesian
system. I could define an element such as

<position coords="DFW", x="236.764", y="129.667"/>

where "DFW" is a predefined coordinate system.

I'm new to XML, and I'd like to know if it is possible to define a
schema that would enforce consistency for both options and perhaps
others as well. The trick here is that for the WGS84 coordinate
system, the coordinate attributes are lat and lon, whereas for the DFW
system they are x and y. Is it possible to write a schema to require
this? Thanks.
Jul 20 '05 #1
2 1302


Russ wrote:
Suppose I want to specify a position on the earth. I could define an
element such as

<position coords="WGS84", lat="34.56223", lon="-121.8277"/> ^^^ ^^^
I am not sure why you have those commas, that is not well-formed.
where lat and lon are latitude and longitude in the WGS84 coordinate
system. Now suppose I also want to have the option of specifying the
position in another coordinate system, a locally level cartesian
system. I could define an element such as

<position coords="DFW", x="236.764", y="129.667"/>

where "DFW" is a predefined coordinate system.

I'm new to XML, and I'd like to know if it is possible to define a
schema that would enforce consistency for both options and perhaps
others as well. The trick here is that for the WGS84 coordinate
system, the coordinate attributes are lat and lon, whereas for the DFW
system they are x and y. Is it possible to write a schema to require
this?


Well, it is easy to define an element where the coords attribute is
mandatory and the other optional, e.g. a document alike

<?xml version="1.0" encoding="UTF-8"?>
<positions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="test20040208Xsd.xml ">
<position coords="WGS84" lat="34.56223" lon="-121.8277" />
<position coords="DFW" x="236.764" y="129.667" />
</positions>

then validates against

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="positions">
<xs:complexType>
<xs:sequence>
<xs:element ref="position" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="position">
<xs:complexType>
<xs:attribute name="coords" type="coordsType" use="required" />
<xs:attribute name="lat" type="xs:double" />
<xs:attribute name="lon" type="xs:double" />
<xs:attribute name="x" type="xs:double" />
<xs:attribute name="y" type="xs:double" />
</xs:complexType>
</xs:element>

<xs:simpleType name="coordsType">
<xs:restriction base="xs:string">
<xs:enumeration value="WGS84" />
<xs:enumeration value="DFW" />
</xs:restriction>
</xs:simpleType>

</xs:schema>

That is not very restrictive however as you could also have an element
<position coords="DFW" lat="42" lon="42" />

You might want to choose a different structure than putting all
information in attributes.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
In article <be**************************@posting.google.com >,
Russ <18********@sneakemail.com> wrote:

% others as well. The trick here is that for the WGS84 coordinate
% system, the coordinate attributes are lat and lon, whereas for the DFW
% system they are x and y. Is it possible to write a schema to require
% this? Thanks.

Not with w3c schemas. You'd need to move the coordinate system to the
element level, something like

<position><wgs84 lat='34.56223' lon='-121.8277'/></position>
<position><dfw x='236.764' y='129.667'/></position>

I believe you can do it the way you want with schematron.
--

Patrick TJ McPhee
East York Canada
pt**@interlog.com
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: SB | last post by:
I have an assignment where we are supposed to mimic a scheduler routine of an OS. We are supposed to schedule some processes, an each process has the following attributes... - process id -...
1
by: Tony Johansson | last post by:
Hello! I'm reading a book about C++ and there is something that I don't understand so I ask you. I have marked the section from the book that is of intertest by tagging it with BOOK START HERE...
6
by: Tim Mavers | last post by:
I have a series of database objects that represent things such as people, accounts, etc. I have a set of options (boolean) that I need to add to these objects. Normally I would just create a bit...
6
by: Developer | last post by:
Hello, I'm experimenting with and XmlTextReader sample, and don't understand how the attributes are being processed. Here's the input: <xsd:element name="AA" type="BB"...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
1
by: Marcel Hug | last post by:
Hello NG ! I have a tricky question about dataSet and dataTable. In my app I have 2 databases. In the first (called A1) database are the whole datas but I'm interesting in one table tbl1 (with 20...
11
by: Doru Roman | last post by:
Hello, I got a test and some of the questions were: A collection a files, which is the basic unit of .NET programming, is called: 1. package 2. assembly 3. library 4. copybook
7
by: Ryan | last post by:
I'm in the process of learning more about building my ASP.NET website to use my SQL datastore and am a bit confused about how ADO.NET works with ASP.NET. This Microsoft article implies that using...
28
by: Alan Isaac | last post by:
I have a class whose instances should only receive attribute assignments for attributes that were created at inititialization. If slots are not appropriate, what is the Pythonic design for this? ...
4
by: RobG | last post by:
I have always accessed attributes such as disabled using the DOM element property, however I was wondering about implementing a more generic function to get the values of attributes - which of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.