473,326 Members | 2,148 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,326 software developers and data experts.

XML Schema - Custom types and Attributes

Say I have the following (simplistic) schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="RootNode">
<xs:complexType>
<xs:sequence>
<xs:element name="FirstChildElement" type="Integer8Type" minOccurs="1"/>
<xs:element name="SecondChildElement" type="Integer8Type"
minOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="Integer8Type">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="99999999"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

I have "Integer8Type" as a custom type. Now, keeping it so that
my "FirstChildElement" element is of "Integer8Type", how can I
define that the "FirstChildElement" element has an attribute? I've
looked everywhere I can think of and I can't find an example that
would keep that element as type "Integer8Type". It always shows
that I'd have to make the "FirstChildElement" element a complex
type.
Could anyone point me in the right direction where I can find the
relevant information on defining attributes for custom typed
elements?

thnx,
Christoph
Jul 20 '05 #1
3 6287
"Sorrow" <jc*****@yahoo.com> writes:
I have "Integer8Type" as a custom [simple] type. Now, keeping it so that
my "FirstChildElement" element is of "Integer8Type", how can I
define that the "FirstChildElement" element has an attribute?


You can't get there from here.

If you had defined Integer8Type as a complex type with simple content,
_then_ you could <redefine> it by extension to add an attribute.

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jul 20 '05 #2
> > I have "Integer8Type" as a custom [simple] type. Now, keeping it so
that
my "FirstChildElement" element is of "Integer8Type", how can I
define that the "FirstChildElement" element has an attribute?

You can't get there from here.
If you had defined Integer8Type as a complex type with simple content,
_then_ you could <redefine> it by extension to add an attribute.


Perhaps you can provide an example? I'm still just learning.

thnx,
Christoph
Jul 20 '05 #3
"Sorrow" <jc*****@yahoo.com> writes:
> I have "Integer8Type" as a custom [simple] type. Now, keeping it
> so that my "FirstChildElement" element is of "Integer8Type", how
> can I define that the "FirstChildElement" element has an
> attribute?
You can't get there from here.
If you had defined Integer8Type as a complex type with simple content,
_then_ you could <redefine> it by extension to add an attribute.


Perhaps you can provide an example? I'm still just learning.


schemaV1.xsd:

<xs:complexType name="Integer8Type">
<xs:simpleContent>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="99999999"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>

. . .

<xs:element name="FirstChildElement" type="Integer8Type"/>

schemaV2.xsd:

<xs:redefine schemaLocation="schemaV1.xsd">
<xs:complexType name="Integer8Type">
<xs:simpleContent>
<xs:extension base="Integer8Type">
<xs:attribute name="something" type="somethingElse"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:redefine>

ht
--
Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
Half-time member of W3C Team
2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
Fax: (44) 131 650-4587, e-mail: ht@inf.ed.ac.uk
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
Jul 20 '05 #4

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

Similar topics

6
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. ...
2
by: Victor | last post by:
I have a Schema with some elements which are "types" or objects, and some elements which correspond to instances of the types. How can I specify that a <locationInstance> must have an attribute...
0
by: Philippe Poulard | last post by:
People familiar with DTD, Relax NG, W3C XML Schema, Schematron, and that are aware of more recent works such as DSDL should recognize all of them in the Active Schema Language. Anyway, ASL...
3
by: Rohit Sharma | last post by:
Hi all.. ..NET + MSXML platform....VB Need to build a list of all the entities and attributes to allow the user to do search...how can i do that from the schema ?? Cheers Rohit
1
by: Ryan | last post by:
I have a very complex XDR schema that uses namespaces: xmlns="urn:schemas-microsoft-com:xml-data" xmlns:b="urn:schemas-microsoft-com:BizTalkServer" xmlns:d="urn:schemas-microsoft-com:datatypes"...
0
by: c j anderson, mcp | last post by:
Core Question: Is there a better way to dynamically pull the allowed values of an attribute out of a dataset's schema. I have an XML file that contains a string element with two attributes,...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
0
by: akshaychand | last post by:
Hi, I am designing a Schema Editor using the Schema Object Model in .NET 2.0. I am currently facing an problem wherein I want to list all the built-in data types as well as the custom types that...
0
by: mk189 | last post by:
Hi, I am trying to create XML schema of custom markup language, enriched by XHTML. In simplified version, the XML documet could look like that: <a:alarm-manual xmlns:a="alarm-manual"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.