Hi,
I am looking for a way to validate IP addresses using XML Schemas. The
following is what i used:
<xsd:simpleTy pe name="IPType">
<xsd:restrictio n base="xsd:strin g">
<xsd:pattern value="(([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] |
25[0-5])\.){3}
([1-9]?[0-9] | 1[0-9][0-9] |
2[0-4][0-9] | 25[0-5])"/>
</xsd:restriction >
</xsd:simpleType>
I think the regular expression is correct, however an XML document with a
valid IP address doesn't pass the validation test.
Can anyone tell me what I can do to solve this?
Many Thanks 8 13541
In article <6g************ *****@newsfe6-gui.ntli.net>,
UndoMiel <un*******@hotm ail.com> wrote: <xsd:pattern value="(([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\.){3} ([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5])"/>
Try removing the spaces.
-- Richard
i did, wont work...
"Richard Tobin" <ri*****@cogsci .ed.ac.uk> wrote in message
news:ce******** ***@pc-news.cogsci.ed. ac.uk... In article <6g************ *****@newsfe6-gui.ntli.net>, UndoMiel <un*******@hotm ail.com> wrote: <xsd:pattern value="(([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9]
| 25[0-5])\.){3} ([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5])"/>
Try removing the spaces.
-- Richard
"UndoMiel" <un*******@hotm ail.com> wrote in message
news:6g******** *********@newsf e6-gui.ntli.net... Hi,
I am looking for a way to validate IP addresses using XML Schemas. The following is what i used:
<xsd:simpleTy pe name="IPType"> <xsd:restrictio n base="xsd:strin g"> <xsd:pattern value="(([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\.){3} ([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5])"/> </xsd:restriction > </xsd:simpleType>
I think the regular expression is correct, however an XML document with a valid IP address doesn't pass the validation test.
Can anyone tell me what I can do to solve this?
Many Thanks
I used the regular expression tester at http://www.roblocher.com/technotes/regexp.aspx
to check how well your pattern worked and it seems that for some reason the
order matters (despite what you'd think...)
this
[1-9]?[0-9]|1[0-9][0-9]
is not the same as this
1[0-9][0-9]|[1-9]?[0-9]
Anyway my tests showed that if you reorder it like this
((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0
-9][0-9]|[1-9]?[0-9])
it will work just fine.
Some regular expression expert can tell you why A|B != B|A
So try that, making sure you have no blanks to the left of the alternation
symbol '|' else it will try and match a blank there instead of the previous
digit...
HTH,
Johnny
In article <uDiQc.6675$Uh. 4292@fed1read02 >,
Johnny Kent <re************ *****@hotmail.c om> wrote: this [1-9]?[0-9]|1[0-9][0-9]
is not the same as this 1[0-9][0-9]|[1-9]?[0-9]
It is, according to the XML Schema specification, and other regular
expression languages I'm familiar with.
The operator | binds less tightly than any other operator, including
concatenation.
Which strings did the tester give different results for? And what browser
were you using (it tests the browser's Javascript regular expressions).
And what validator is the original poster using?
-- Richard
"Richard Tobin" <ri*****@cogsci .ed.ac.uk> wrote in message
news:ce******** **@pc-news.cogsci.ed. ac.uk... In article <uDiQc.6675$Uh. 4292@fed1read02 >, Johnny Kent <re************ *****@hotmail.c om> wrote:
this [1-9]?[0-9]|1[0-9][0-9]
is not the same as this 1[0-9][0-9]|[1-9]?[0-9] It is, according to the XML Schema specification, and other regular expression languages I'm familiar with.
Agreed.
Sorry, instead of "(Despite what you'd think)" I should have said "contrary
to the rules of regular expressions"
in my post. The operator | binds less tightly than any other operator, including concatenation.
Which strings did the tester give different results for?
try entering 199 using the patterns above,
none of the 3 browsers I tried (although 2 are really mozilla though they
don't act the same) match 199
using the first pattern [1-9]?[0-9]|1[0-9][0-9]
but all 3 matched 199
using the second pattern 1[0-9][0-9]|[1-9]?[0-9]
And what browser were you using (it tests the browser's Javascript regular expressions).
Same result for both IE5, Mozilla (1.7) and Firefox(0.8.0+)
Guess the tester must be what's bad 'cos it sure ought to work both ways.
Looks like the OP has moved on and left us to keep this alive... :-)
Hi,
I just used XMLSpy and the Topologi validator to validate the XML
document...
I've also tried another regular expression cause i couldnt get the the other
one working... Here it comes:
<xsd:restrictio n base="xsd:strin g">
<xsd:pattern
value="(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-
5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0
-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{
1 }[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])"/>
</xsd:restriction >
It's a bit longer and complicated but it worked fine....
Thanks for ur time guys...
"Johnny Kent" <re************ *****@hotmail.c om> wrote in message
news:ZBEQc.1003 4$Uh.655@fed1re ad02... "Richard Tobin" <ri*****@cogsci .ed.ac.uk> wrote in message news:ce******** **@pc-news.cogsci.ed. ac.uk... In article <uDiQc.6675$Uh. 4292@fed1read02 >, Johnny Kent <re************ *****@hotmail.c om> wrote:
this [1-9]?[0-9]|1[0-9][0-9]
is not the same as this 1[0-9][0-9]|[1-9]?[0-9] It is, according to the XML Schema specification, and other regular expression languages I'm familiar with.
Agreed. Sorry, instead of "(Despite what you'd think)" I should have said
"contrary to the rules of regular expressions" in my post.
The operator | binds less tightly than any other operator, including concatenation.
Which strings did the tester give different results for?
try entering 199 using the patterns above, none of the 3 browsers I tried (although 2 are really mozilla though they don't act the same) match 199 using the first pattern [1-9]?[0-9]|1[0-9][0-9] but all 3 matched 199 using the second pattern 1[0-9][0-9]|[1-9]?[0-9]
And what browser were you using (it tests the browser's Javascript regular expressions).
Same result for both IE5, Mozilla (1.7) and Firefox(0.8.0+) Guess the tester must be what's bad 'cos it sure ought to work both ways. Looks like the OP has moved on and left us to keep this alive... :-)
I just downloaded and installed an eval copy of xmlspy.
I put the following code snippets into two files, checked that they
validated with wrox.validate then loaded into xmlspy and it works and
validates just fine:
file "ip.xml"
<?xml version="1.0"?>
<IPtest xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespace SchemaLocation= "ip.xsd">
<IP>192.168.255 .1</IP>
</IPtest>
file "ip.xsd"
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
<xsd:simpleTy pe name="IPType">
<xsd:restrictio n base="xsd:strin g">
<xsd:pattern
value="(([1-9]?[0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-
9][0-9]|2[0-4][0-9]|25[0-5])"/>
</xsd:restriction >
</xsd:simpleType>
<xsd:element name="IPtest">
<xsd:complexTyp e>
<xsd:sequence >
<xsd:element name="IP" type="IPType" maxOccurs="unbo unded">
</xsd:element>
</xsd:sequence>
</xsd:complexType >
</xsd:element>
</xsd:schema>
I'm using XMLSPY on windows 2000 sp2, it seems to be using the xmlspy
internal validator and is working just fine.
I think you need to check either your syntax (it won't work with spaces
within the ip , or before or after and also won't work if you leave spaces
around the | in the pattern but as I have it above (like your original but
without the spaces) it validates.
HTH,
Johnny
"UndoMiel" <un*******@hotm ail.com> wrote in message
news:It******** ******@newsfe2-gui.ntli.net... Hi,
I just used XMLSpy and the Topologi validator to validate the XML document...
I've also tried another regular expression cause i couldnt get the the
other one working... Here it comes:
<xsd:restrictio n base="xsd:strin g">
<xsd:pattern
value="(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-
5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0 -9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1
]{ 1 }[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])"/>
</xsd:restriction >
It's a bit longer and complicated but it worked fine....
Thanks for ur time guys...
"Johnny Kent" <re************ *****@hotmail.c om> wrote in message news:ZBEQc.1003 4$Uh.655@fed1re ad02... "Richard Tobin" <ri*****@cogsci .ed.ac.uk> wrote in message news:ce******** **@pc-news.cogsci.ed. ac.uk... In article <uDiQc.6675$Uh. 4292@fed1read02 >, Johnny Kent <re************ *****@hotmail.c om> wrote:
>this >[1-9]?[0-9]|1[0-9][0-9] > >is not the same as this >1[0-9][0-9]|[1-9]?[0-9]
It is, according to the XML Schema specification, and other regular expression languages I'm familiar with.
Agreed. Sorry, instead of "(Despite what you'd think)" I should have said
"contrary to the rules of regular expressions" in my post.
The operator | binds less tightly than any other operator, including concatenation.
Which strings did the tester give different results for?
try entering 199 using the patterns above, none of the 3 browsers I tried (although 2 are really mozilla though
they don't act the same) match 199 using the first pattern [1-9]?[0-9]|1[0-9][0-9] but all 3 matched 199 using the second pattern 1[0-9][0-9]|[1-9]?[0-9]
And what browser were you using (it tests the browser's Javascript regular
expressions). Same result for both IE5, Mozilla (1.7) and Firefox(0.8.0+) Guess the tester must be what's bad 'cos it sure ought to work both
ways.
Looks like the OP has moved on and left us to keep this alive... :-)
"UndoMiel" <un*******@hotm ail.com> writes: Hi,
I am looking for a way to validate IP addresses using XML Schemas. The following is what i used:
<xsd:simpleTy pe name="IPType"> <xsd:restrictio n base="xsd:strin g"> <xsd:pattern value="(([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5])\.){3} ([1-9]?[0-9] | 1[0-9][0-9] | 2[0-4][0-9] | 25[0-5])"/> </xsd:restriction > </xsd:simpleType>
I think the regular expression is correct, however an XML document with a valid IP address doesn't pass the validation test.
Note that valid IP addresses may not conform to the pattern you're
going for. Most notably, IPv6 patterns take a radically different
form.
Also, although I think almost everybody uses the 127.0.0.1 format
nowadays, traditionally you could shorten the IP address (e.g., 127.1
is the same thing as 127.0.0.1). I don't know what RFC defines that,
though, and people using IPv4 can always convert to the long form, so
that's not so important. You do need to think about the IPv6
situation, though (even if you simply decide not to handle it). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike:o |
last post by:
I need to validate XML documents (orders) against their schema before
processing. The PurchaseOrder schema that we use references 3 other schemas
using the <imports ...> element. Here is the relationship:
- PurchaseOrder.xsd
- Base.xsd
- Item.xsd
- Party.xsd
These schemas are all located at a public Internet location. The imports
elements within the PurchaseOrder schema look like this:
|
by: Iain |
last post by:
I've got a system which takes an XML file, translates it into an update gram
and then loads it into my database with SQLXML3 (all in dot net).
But it's fragile. And the SQLXML 3 error reporting is not absolutely
wonderful.
So what I want to do is to validate it before I upload it.
When I try and do this I get MILLIONS of errors (well lots) complaining
about elements like ROOT which are part of the
|
by: Robert Reineri |
last post by:
Hello,
New to the XML world and .NET. I have what I believe to be a simple problem,
but I have read the .NET docs till I'm blue in the face and still can't
locate a simple example of how to accomplish this.
I have two strings (C# string type).
One of them contains an XML document.
The other one contains a schema.
|
by: Andy |
last post by:
I am having some trouble validating XML using the XmlValidatingReader.
I have created some xml and used the visual studio to generate the
schema. So I am confident that the xml and schema match.
The problem I am having is that the validation event fires for each
node in the xml. It seems to be completely ignoring the schema that I
have used.
I'm wondering if I need to do something extra to tell the xml which
schema to use.
|
by: Joris Janssens |
last post by:
I'm trying to write a program for validating XHTML 1.1-documents
against the XHTML 1.1 DTD (which is actually the same as validating an
XML-file) but I always get a "(404) Not found" error.
This is the program itself :
********************************************************************
using System;
using System.Xml;
using System.Xml.Schema;
| |
by: Shailendra Batham |
last post by:
hi guys
I need your suggestions / opinion for doing this the right way.
I have a XML and a Schema for the same
What I want is when its validated against the schema, it should give custom errors saying what happened and where......
is it possible to do that ?
for eg. if the Attribute is missing or invalid in the following element <Watch ID="999d999">
|
by: Craig Beuker |
last post by:
Hello,
I am experimenting with this XmlValidatingReader and have a question
about how it is working (or not working as would be the case)
The sample documents and code are included at the end of the post. I am
using VS.net 2003, .Net 1.1, Win2k Server
I have a simple schema and a simple XML document.
|
by: Wallace |
last post by:
Hi all,
I have a problem on validating a xml fragment using a single namespace
schema which spread across multiple schema files using include in the
master schema file. No matter how I change the xml fragment (to include
default namespace xmlns='urn:xxx:yy' and any other namespace it may
have), I still get the same error.
'urn:xxx:yy:Header' element is not declared. An error occurred at , (1,
2).
|
by: Chris Lieb |
last post by:
I have an XML Schema file that I know is correct becuase I currently
use it in a VB6 program to validate XML documents. Also, if I load an
XML file into VS2005 that is not valid against this schema, I get XML
errors (blue squigglies) in a few places, which indicates to me that I
should get validation errors while validating through code.
When I try to validate an invalid document, I never get any validation
errors. I have tried many...
|
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...
|
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: 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: 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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |