473,802 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[XML Schema] Attributes

Is it possible to make an attribute required, optional, or forbidden
depending on the value of another attribute? How about changing
element content based on an attribute?

--
I am only a mirage.
Aug 11 '05 #1
3 1250
On Thu, 11 Aug 2005 04:33:03 GMT, kelvSYC <ke*****@no.ema il.shaw.ca> wrote:
Is it possible to make an attribute required, optional, or forbidden
depending on the value of another attribute? How about changing
element content based on an attribute?


Sure - just not with W3C XML Schema <g>. You can supplement XML Schema with
Schematron or just write a custom XSL transform that produces output
describing any rules if finds to be broken.
Aug 11 '05 #2
In article <g9************ *************** *****@4ax.com>, Steve
Jorgensen <no****@nospam. nospam> wrote:
On Thu, 11 Aug 2005 04:33:03 GMT, kelvSYC <ke*****@no.ema il.shaw.ca> wrote:
Is it possible to make an attribute required, optional, or forbidden
depending on the value of another attribute? How about changing
element content based on an attribute?


Sure - just not with W3C XML Schema <g>. You can supplement XML Schema with
Schematron or just write a custom XSL transform that produces output
describing any rules if finds to be broken.


What about other schema languages? Does RELAX NG, for example, have
this ability?

--
I am only a mirage.
Aug 11 '05 #3
On Thu, 11 Aug 2005 06:35:59 GMT, kelvSYC <ke*****@no.ema il.shaw.ca> wrote:
In article <g9************ *************** *****@4ax.com>, Steve
Jorgensen <no****@nospam. nospam> wrote:
On Thu, 11 Aug 2005 04:33:03 GMT, kelvSYC <ke*****@no.ema il.shaw.ca> wrote:
>Is it possible to make an attribute required, optional, or forbidden
>depending on the value of another attribute? How about changing
>element content based on an attribute?


Sure - just not with W3C XML Schema <g>. You can supplement XML Schema with
Schematron or just write a custom XSL transform that produces output
describing any rules it finds to be broken.


What about other schema languages? Does RELAX NG, for example, have
this ability?


I'm not a RELAX NG user because it isn't supported for what I need, but I am
led to understand that it cannot do things like that, and that Scehamtron is
pretty much the only schema language that can.

You can embed Schematron in either XML Schema or in RELAX NG, and most decent
XML editors can use the embedded Schematron if you tell them to (I use
<oXygen/> for this).

I'm starting to see, though, that even though it's a separate file and a bit
harder to keep clean and legible, using a custom xsl file might be the better
way to go. For one thing, you can use XSLT 2.0 without worrying about whether
your editor supports XSLT 2.0 functionality in Schematron, and for another
thing, you don't have to figure out how you're going to use Schematron to
validate documents in an application using, say, MSXML.

Aug 11 '05 #4

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

Similar topics

6
2494
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...
3
4610
by: Bill C. | last post by:
Hi, I've got a simple console app that just reads an XML file into a DataSet then prints out a description of each table in the DataSet, including column names and row values for each column. I'm getting some strange results depending the input XML file I use. I was wondering if somebody could help me understand what is going on or point me to a good reference. The code for my program looks like this:
1
5332
by: harry | last post by:
Hello, not certain if this should go here or ado.net but I'm trying to create an XSD on the fly (due to the fact that our dataaccess component is a legacy component which returns data in an xml format) Now I can create all of the schema using the .Net frameworks class except for being able to add the msdata:isDataSet="true"
3
10291
by: Joe98765 | last post by:
I have data coming from SQL Server and need to write out some XML. I have a schema(xsd) for this XML file. Right now I am bringing in the DataSet and writing out the elements and attributes myself using xmltextwriter to match schema without really using the xsd at the time of writing. The file I create validates but I was wondering is there a better way? I see things like inferschema method off of dataset, can this be used? How do you...
2
9237
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>
3
1807
by: Nick Gilbert | last post by:
Hi, I have to send an array of prices for a list of products over XML. Currently my XML data looks like this: <ArrayOfProd> <Prod Code="productcode001"> <Prices> <P F="2005-01-01" T="2005-09-09" Q="10" V="27.50" />
3
5000
by: John Glover | last post by:
To whoever can help, I've been having a problem with XML deserialization lately. I needed to serialize and deserialze two objects which inherited from Hashtable. Because IDictionary implementations cannot be serialized, I had to take matters into my own hands by implementing a wrapper over the Hashtable which implemted IXmlSerializable. I called it XmlHashtable. It has, among other convenience methods, a method
1
19079
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">
0
3366
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" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="alarm-manual alarm-manual.xsd" <h:p>Text ... <a:par-value name="myName"/... text </h:p>
4
1231
by: Tony Johansson | last post by:
Hello! I know this might not be the appropriate forum for xml question. But xml is so important for .NET I hope my basic question can be answered in this forum. I just wonder does every xml document have a XSD schema or XDR schema ? Is it possible to say that the purpose for schema is to have a definition for syntax.
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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,...
0
10538
Oralloy
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...
0
10305
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 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...
1
10285
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,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7598
isladogs
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...
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
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...

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.