Results 1 to 2 of 2

Thread: XML: Newbie with XSD and attributes

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    XML: Newbie with XSD and attributes

    I'm having trouble with attributes given an .xsd. This is the schema.

    My task, for now, is to create PersonTypeElement. I'm creating the xml in a text editor and validating that with VB.NET 1.0 code. The code was copied from a built in example.

    I've made an xml document that validates, it's more than this, but for simplicity, let's say it looks like this:

    Code:
    <?xml version="1.0"?>
    
    <PersonTypeElement
    xmlns="http://www.it.ojp.gov/jxdd/prerelease/3.0.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.it.ojp.gov/jxdd/prerelease/3.0.0.0 jxdds.xsd">
    
    	<PersonPhysicalDetails>
    	<PersonHeightMeasure>73</PersonHeightMeasure>
    	</PersonPhysicalDetails>
    
    </PersonTypeElement>
    It's obvious from the xsd that they're expeciting an attribute to describe the unit measure. However, whenever I add an atribute to the element, my .NET coded validation fails.

    For example,
    Code:
    <?xml version="1.0"?>
    
    <PersonTypeElement
    xmlns="http://www.it.ojp.gov/jxdd/prerelease/3.0.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.it.ojp.gov/jxdd/prerelease/3.0.0.0 jxdds.xsd">
    
    	<PersonPhysicalDetails>
    	<PersonHeightMeasure PersonHeightUnitCode="in">73</PersonHeightMeasure>
    	</PersonPhysicalDetails>
    
    </PersonTypeElement>

    As I don't know what I'm doing, I've tried lots of attribute names, but can't get anything to validate.

    Any help is much appreciated,
    Mike

  2. #2

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    XML: Newbie with XSD and attributes - Resolved

    FWIW, figured it out. Need to use namespaces. So this
    Code:
    <PersonTypeElement
    xmlns="http://www.it.ojp.gov/jxdd/prerelease/3.0.0.0"
    becomes
    Code:
    <PersonTypeElement
    xmlns:jdd="http://www.it.ojp.gov/jxdd/prerelease/3.0.0.0"
    and then jdd: is prepended to all element/attribute opening and closing tags.

Posting Permissions

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



Click Here to Expand Forum to Full Width