Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2006, 04:59 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default restrictions

hello

how can I make this restrictions:
1. if I need to recieve a string/integer, I want to make sure that I want get an empty string or empty integer
2. what do I need to do in order to recieve on 2 letters/digits and the letters must be upper case. (can recieve either digits/letters.
3. how can I make a string/integer with max number of letter/digits (not fix, since I dont know how many symbols I will enter)

thanks
Kfir

 
Old April 26th, 2006, 05:07 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I assume you're asking about how to impose these constraints using XML Schema?

1. (I assume by "I want get" you mean "I won't get"). There's no such thing as an empty integer so you don't need to prevent it. You can prevent an empty string using <xs:minLength value="1"/>

2. <xs:pattern value="[A-Z0-9][A-Z0-9]"/>

3. for string: maxLength. For integer, specify maxInclusive value="999999" say.

These are very basic questions, I'm surprised you found it difficult to find the answers. Don't try using XML Schema without a reference book on your desk - even experienced users find it hard to remember the syntax.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 26th, 2006, 06:30 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for 1.
is it correct to write it like that?
<xs:attribute name="internal_name" type="xs:string" use="required" >
    <xs:minLength value="1"/>
</xs:attribute>

 
Old April 26th, 2006, 06:40 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

No, you need to declare an <xs:simpleType> and an <xs:restriction>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 26th, 2006, 06:49 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

when I am trying to write
<xs:attribute name="internal_name" type="xs:string" use="required" >
    <xs:simpleType>
        <xs:minLength value="1"/>
    </xs:simpleType>
</xs:attribute>

it says that it is unexpected in simpleType expected xs:annotation, restriction, list or union.
when I write the same thing with out the simpleType it still that there is an error that it is expected to be simpleType .

sorry for all the Q but it is the first time I am working with this tool.
thank you very much for your help
kfir

 
Old April 26th, 2006, 06:51 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You need an xs:restriction element inside the xs:simpleType

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 27th, 2006, 12:34 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

do you have a good reference book to recommand that I can find on the net?

thank you

 
Old April 27th, 2006, 02:58 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

We're on a Wrox site, so I'm a bit reluctant to recommend the competition: but I must admit that of the three XML Schema books on my bookshelf, the one I turn to first is Eric van der Vlist (O'Reilly).

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 27th, 2006, 03:27 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Purpose of this forum and restrictions jminatel Visual Studio 2005 2 April 1st, 2007 11:56 PM
restrictions on attributes kfir XML 2 May 30th, 2006 04:35 AM
Modeling with restrictions on attribute value jacob XML 0 June 3rd, 2005 07:01 AM
Purpose of this forum and restrictions jminatel ASP.NET 2.0 Basics 2 January 27th, 2005 10:43 AM
Purpose of this forum and restrictions jminatel .NET Framework 2.0 0 July 21st, 2004 03:27 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.