Results 1 to 7 of 7

Thread: XML Schema Definition Question

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Posts
    1,891
    Thanks
    218
    Thanked
    61 times in 53 posts
    • jonathan_phang's system
      • Motherboard:
      • Asus Rampage III Extreme
      • CPU:
      • i7 930 @ 4.2 ghz (200x21)
      • Memory:
      • 12GB Corsair XMS3 1600
      • Storage:
      • Crucial M4 128GB SSD + Misc Data Drive
      • Graphics card(s):
      • EVGA GTX 1080 FTW
      • PSU:
      • Corsair HX850 Modular
      • Case:
      • Antec 300
      • Operating System:
      • Windows 7 x64
      • Monitor(s):
      • Asus PB278Q (27" 2560x1440)
      • Internet:
      • Virgin Media 100mb

    XML Schema Definition Question

    Hi all - just started doing some XML/XSD at work and just wanted to ask something. I have an element with several children, lets say that they are just all strings, is there a way to be able to restrict the length of each one to x characters, WITHOUT having to make that element a simpletype?

    Its just that i could have lots of them eventually, and dont want to have to have it nested too many times and it looks unwieldy. is there a way to achieve this inline?

    Code:
    <xs:element name="myThing" >
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element name="model" type="xs:string"/>
    				<xs:element name="terminal" type="xs:string"/>
    				<xs:element name="userID" type="xs:string"/>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    Thanks for any help - sure it will be simple...

    JP

  2. #2
    Senior Member
    Join Date
    Sep 2006
    Location
    Cheltenham
    Posts
    269
    Thanks
    1
    Thanked
    8 times in 8 posts
    • Rishi's system
      • Motherboard:
      • Asus P5B
      • CPU:
      • Intel E6600 2.4Ghz
      • Memory:
      • Corsair 2GB - PC6400
      • Storage:
      • 1 x 250GB Maxtor 16MB Cache
      • Graphics card(s):
      • None :(
      • PSU:
      • hmmm :/
      • Case:
      • Black - Standard
      • Monitor(s):
      • 19" TFT 8ms
      • Internet:
      • Orange (I think!)

    Re: XML Schema Definition Question

    .: Rishi :.

  3. #3
    Senior Member
    Join Date
    Feb 2004
    Posts
    1,891
    Thanks
    218
    Thanked
    61 times in 53 posts
    • jonathan_phang's system
      • Motherboard:
      • Asus Rampage III Extreme
      • CPU:
      • i7 930 @ 4.2 ghz (200x21)
      • Memory:
      • 12GB Corsair XMS3 1600
      • Storage:
      • Crucial M4 128GB SSD + Misc Data Drive
      • Graphics card(s):
      • EVGA GTX 1080 FTW
      • PSU:
      • Corsair HX850 Modular
      • Case:
      • Antec 300
      • Operating System:
      • Windows 7 x64
      • Monitor(s):
      • Asus PB278Q (27" 2560x1440)
      • Internet:
      • Virgin Media 100mb

    Re: XML Schema Definition Question

    Thanks for that, but the restriction on length is done based on a transformation language. What I’m after is a way to restrict the values that are sent to me (I’m doing a c# web service) - I know that I could leave out the validation from the XML schema and just try to catch everything in the web service itself, but I just want to know… 

  4. #4
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s

    Re: XML Schema Definition Question

    I would be inclined to catch the values you don't want before they get to the XML, seems like a more logical place to restrict things.

  5. #5
    Senior Member
    Join Date
    Feb 2004
    Posts
    1,891
    Thanks
    218
    Thanked
    61 times in 53 posts
    • jonathan_phang's system
      • Motherboard:
      • Asus Rampage III Extreme
      • CPU:
      • i7 930 @ 4.2 ghz (200x21)
      • Memory:
      • 12GB Corsair XMS3 1600
      • Storage:
      • Crucial M4 128GB SSD + Misc Data Drive
      • Graphics card(s):
      • EVGA GTX 1080 FTW
      • PSU:
      • Corsair HX850 Modular
      • Case:
      • Antec 300
      • Operating System:
      • Windows 7 x64
      • Monitor(s):
      • Asus PB278Q (27" 2560x1440)
      • Internet:
      • Virgin Media 100mb

    Re: XML Schema Definition Question

    The XML itself is coming from some hardware vendors (Which i cant explicitly control), so they can try to implement that but I'm probably just going to perform the validation from the web service - that way i can control the exact error going back as a response.

    Thanks for the advice though!

  6. #6
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s

    Re: XML Schema Definition Question

    My mistake, I assumed that the flow would be:

    data > webservice > XML output

    if it is more like:

    data > XML input > webservice > response.

    Then if you can't control the data or XML, then yes, in the webservice would be the best place to validate. The only problem comes with passing back erroneous XML input, but there are ways round that

  7. #7
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts

    Re: XML Schema Definition Question

    I'm not sure i've understood fully, but couldnt each child element of myThing be a simpletype to which you could apply an xsd:restriction? You could then make these children of an xsd:group instead and use that to control the child elements of myThing, or have I misunderstood entirely?
    To err is human. To really foul things up ... you need a computer.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Not a very technical Question, but a Question none the less.
    By chip35 in forum Help! Quick Relief From Tech Headaches
    Replies: 6
    Last Post: 24-03-2007, 09:05 PM
  2. How to connect an XML document with XML Schemas??
    By hegaroo in forum Help! Quick Relief From Tech Headaches
    Replies: 1
    Last Post: 10-01-2007, 06:41 PM
  3. Replies: 1
    Last Post: 21-12-2006, 03:06 AM
  4. Personal Question game.....
    By Kitty in forum General Discussion
    Replies: 394
    Last Post: 29-01-2006, 11:50 AM
  5. Quick Question: PSU's with 1x120mm fan question
    By philyau in forum PC Hardware and Components
    Replies: 10
    Last Post: 05-09-2005, 02:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •