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 May 4th, 2006, 02:41 AM
Authorized User
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kfir
Default data type

hello

my question is:
I have an attribute (lets name it kfir) that can recieve parameters
ACTION, TIME1, etc (meaning uppercase charcters and numbers together or not together). I dont have a limit on the size of what is written on the xml file. how can I declare the data type when I dont have a limit. (I thought of writing

<xs:restriction base="xs:string">
                        <xs:pattern value="[A-Z0-9][A-Z0-9]"/>
                    </xs:restriction>

or add some more [A-Z0-9] but I want it to be that no matter how long what I will recieve in the xml file, I will know how to handle it.
is there other and better way to declare the data type?

thanks

kfir
__________________
kfir
 
Old May 4th, 2006, 03:14 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

An asterisk * means any number of times so assuming you need at least one character I think you need:
Code:
<xs:pattern value="[A-Z0-9][A-Z0-9]*"/>
--

Joe (Microsoft MVP - XML)
 
Old May 4th, 2006, 03:19 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Try the pattern value="[A-Z0-9]*"

And do get yourself a reference book on XML Schema and read it once through. It's fine asking questions on a forum when you're stuck, but it's not an efficient way to do your basic learning.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 4th, 2006, 03:24 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Bit of a daze this morning, a plus + means one or more times so:
Code:
<xs:pattern value="[A-Z0-9]+"/>

--

Joe (Microsoft MVP - XML)
 
Old May 7th, 2006, 01:33 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I declared this
<xs:pattern value="([A-Z0-9])+"/>

and my Q is, if I the value that I recieve from the xml could be like this for example
TIME1_NEW or TIME1 or ACTIVE, etc (could be mixed letters and numbers and signals ('_'). at first I declared the type as a string but I dont think that it means the values with '_' sign. my Q is what restriction base do I need to give in order to cover all the possibilities?

thanks

 
Old May 7th, 2006, 05:19 AM
Authorized User
 
Join Date: Apr 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kfir
Default

never mind, I managed.
thanks any way

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

I'm always rather surprised to see questions like this. Where did you look for the information? Have you read about regular expressions, and not understood the information - or are you just coming here to save yourself the trouble? I can show you how to extend the regular expression to include "_", but my worry is that you'll then just come back with another question asking how to add the next feature.

In short, I need to understand what concept you haven't understood.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Which data type should I use? logmaster C# 0 January 2nd, 2006 10:06 AM
Changing data type JLN Pro VB 6 1 July 13th, 2004 12:49 PM
Data Type error but it is the correct type Mitch SQL Server 2000 2 March 19th, 2004 11:31 AM
Data Type Conversion owain SQL Language 5 October 31st, 2003 12:31 PM
data type limitations trangd MySQL 0 October 16th, 2003 11:34 AM





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