Hi,
I'm new to XML and just started reading some documentation on W3C
compliant schemas recently. The XML file I'm generating is for an
embedded application and so size is of extreme importance. The
information I want to save in this XML file is the attributes of the
members of a structure.
Now lets say there is a member variable that is an array (of length
10), so I'd want the following line in that variable's attributes:
<width>10</width>
Now if I have another variable that is not an array then I'd like to
avoid the width specification altogether rather than have:
<width>1</width>
Does the W3C schema support a variable number of attributes so that
the parser can assign default values for the missing attributes? If it
doesn't then can someone please point me to a schema format and a
parser that does support this?
I am currently planning on using the Xerxes parser.
Thanks in advance,
Ashish. 4 2976 as************* **@gmail.com wrote:
Now lets say there is a member variable that is an array (of length
10), so I'd want the following line in that variable's attributes:
<width>10</width>
Now if I have another variable that is not an array then I'd like to
avoid the width specification altogether rather than have:
<width>1</width>
Does the W3C schema support a variable number of attributes so that
the parser can assign default values for the missing attributes?
I don't understand what you are asking about. In XML terminology
<width>10</width>
is an element with name 'width' and simple contents '10' so there is no
attribute at all in your example.
If you want to know whether you can define default values for elements
with W3C XSD schemas then the answer is yes, you can do that:
<xs:element name="width" type="xs:int" default="1"/>
However the element needs to be present but empty for the default value
to be applied.
--
Martin Honnen http://JavaScript.FAQTs.com/
On Jun 20, 9:39 am, Martin Honnen <mahotr...@yaho o.dewrote:
ashish.sadanan. ..@gmail.com wrote:
Now lets say there is a member variable that is an array (of length
10), so I'd want the following line in that variable's attributes:
<width>10</width>
Now if I have another variable that is not an array then I'd like to
avoid the width specification altogether rather than have:
<width>1</width>
Does the W3C schema support a variable number of attributes so that
the parser can assign default values for the missing attributes?
I don't understand what you are asking about. In XML terminology
<width>10</width>
is an element with name 'width' and simple contents '10' so there is no
attribute at all in your example.
If you want to know whether you can define default values for elements
with W3C XSD schemas then the answer is yes, you can do that:
<xs:element name="width" type="xs:int" default="1"/>
However the element needs to be present but empty for the default value
to be applied.
--
Martin Honnen http://JavaScript.FAQTs.com/
Martin,
I shouldn't have used the word attribute. What I meant is can I skip
the element 'width' so that the parser automatically assigns the
default value? From your answer it seems that I can't if I want the
schema to be W3C compliant, is there any other schema format that'll
let me do this?
Thanks for your response,
Ashish. as************* **@gmail.com wrote:
I shouldn't have used the word attribute. What I meant is can I skip
the element 'width' so that the parser automatically assigns the
default value? From your answer it seems that I can't if I want the
schema to be W3C compliant, is there any other schema format that'll
let me do this?
If you want absence of an element to imply a default value, I'd suggest
you implement that in the application logic, or in a processing stage
such as a stylesheet, rather than in the schema.
Remember: The schema's job is not to define all the semantics of a
document. It's to define higher-level syntax and to *help* you define
the semantics.
--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Hi Ashish,
If you use attributes instead of elements, you can achieve what you want.
<xs:attribute name="width" type="xs:intege r" default="1"/>
In this case, if you don't provide width attribute in the xml file, the
processor will insert it and give it the value of 1.
--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
<as************ ***@gmail.comwr ote in message
news:11******** **************@ m36g2000hse.goo glegroups.com.. .
On Jun 20, 9:39 am, Martin Honnen <mahotr...@yaho o.dewrote:
>ashish.sadanan ...@gmail.com wrote:
Now lets say there is a member variable that is an array (of length
10), so I'd want the following line in that variable's attributes:
<width>10</width>
Now if I have another variable that is not an array then I'd like to
avoid the width specification altogether rather than have:
<width>1</width>
Does the W3C schema support a variable number of attributes so that
the parser can assign default values for the missing attributes?
I don't understand what you are asking about. In XML terminology <width>10</width> is an element with name 'width' and simple contents '10' so there is no attribute at all in your example. If you want to know whether you can define default values for elements with W3C XSD schemas then the answer is yes, you can do that: <xs:element name="width" type="xs:int" default="1"/> However the element needs to be present but empty for the default value to be applied.
--
Martin Honnen http://JavaScript.FAQTs.com/
Martin,
I shouldn't have used the word attribute. What I meant is can I skip
the element 'width' so that the parser automatically assigns the
default value? From your answer it seems that I can't if I want the
schema to be W3C compliant, is there any other schema format that'll
let me do this?
Thanks for your response,
Ashish. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
I've made a small list of some good and bad points of both. These
points don't really go into the grammar aspects of these languages,
but are more about secondary aspects. The grammar aspects are
different, but both are suitable for validating...
|
by: Mark Constant |
last post by:
All I want to do is have a xml file like this
<Entertainment>
<Movie>
<Title>(Title Here)</Title>
<Rating>(Rating Here)</Title>
</Movie>
<Movie>
<Title>(Title Here)</Title>
<Rating>(Rating Here)</Title>
|
by: Ralf Wahner |
last post by:
Dear Masters of XML
As I'm new to XML Schema I dare to ask a possibly recurring
question: Given an element <elem> with two attributes @a and
@b. The attributes are bound by the condition, that either both
or none must be present, i.e.
<elem a="val_a" b="val_b"/> or <elem/>
is valid, whilst
|
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
|
by: Shailendra Batham |
last post by:
Hello Gurus,
I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that.
here is my XML and the XML Schema
<?xml version="1.0" encoding="utf-8"?>
<Book ID="1000000000">
<Name>XML Basic</Name>
<Comments>Whatever</Comments>
| |
by: Martin |
last post by:
Hi,
I have a xml file like the one below
<?xml version="1.0" encoding="utf-8"?><e1
xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2"
e1:rest="345"/>
If I try to create a schema for it with Visual Studio, I get the error
"Failed to create a schema for this data file because:
|
by: craig.wagner |
last post by:
I have a situation where I need to carry additional information in an
XML Schema. What I've found to appear to work is doing something like
the following:
<xs:schema xmlns:xs=" http://www.w3.org/2001/XMLSchema"
xmlns:xx="http://www.mycompany.com">
<xs:complexType name="SomeType">
<xs:sequence>
<xs:element name="AccountNumber" type="xs:int"
xx:errorAction="fail"/>
|
by: paul_zaoldyeck |
last post by:
does anyone know how to validate an xml file against multiple defined
schema?
can you show me some examples?
i'm making here an xml reader..
thank you
|
by: Mikus Sleiners |
last post by:
I have a task to create xml document from c# code.
I have example of that document should look like and also a xml schema.
I wonder if i can use this xml schema somehow ?
This is schema:
<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |