Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Sun, 29 Jun 2008 10:10:52 +0100,    group: microsoft.public.xml        back       


XML Design   
Hi All,

Bit of a newbie when it comes to designing XML layouts so I'm after some 
advice.

I have a record Risk, which has elements of severity (low, medium, high), 
description (string), effective date (date).  Related to that I have another 
record, Response, which has the elements of severity (none, low, medium, 
high), and description (string).

What would be the "ideal" way of laying these out in XML?  Currently I have:

<riskRecords>
  <riskRecord>
    <riskRecordSeverity></riskRecordSeverity>
    <riskRecordDescription></riskRecordDescription>
    <riskRecordEffectiveDate></riskRecordEffectiveDate>

    <riskRecordResponse>
      <riskRecordReponseSeverity></riskRecordResponseSeverity>
      <riskRecordResponseDescription></riskRecordResponseDescription>
    </riskRecordResponse>
  <riskRecord>

  <riskRecord>
    <riskRecordSeverity></riskRecordSeverity>
    <riskRecordDescription></riskRecordDescription>
    <riskRecordEffectiveDate></riskRecordEffectiveDate>

    <riskRecordResponse>
      <riskRecordReponseSeverity></riskRecordResponseSeverity>
      <riskRecordResponseDescription></riskRecordResponseDescription>
    </riskRecordResponse>
  <riskRecord>
</riskRecords>

Also what would be the XSD for this?

All advice most appreciated.

Regards,


Adam M.
date: Sun, 29 Jun 2008 10:10:52 +0100   author:   Adam David Moss ess

Re: XML Design   
"Adam David Moss" <no@email.address> wrote in message 
news:Omc6Agc2IHA.5664@TK2MSFTNGP02.phx.gbl...
> Hi All,
>
> Bit of a newbie when it comes to designing XML layouts so I'm after some 
> advice.
>
> I have a record Risk, which has elements of severity (low, medium, high), 
> description (string), effective date (date).  Related to that I have 
> another record, Response, which has the elements of severity (none, low, 
> medium, high), and description (string).
>
> What would be the "ideal" way of laying these out in XML?  Currently I 
> have:
>
> <riskRecords>
>  <riskRecord>
>    <riskRecordSeverity></riskRecordSeverity>
>    <riskRecordDescription></riskRecordDescription>
>    <riskRecordEffectiveDate></riskRecordEffectiveDate>
>
>    <riskRecordResponse>
>      <riskRecordReponseSeverity></riskRecordResponseSeverity>
>      <riskRecordResponseDescription></riskRecordResponseDescription>
>    </riskRecordResponse>
>  <riskRecord>
>
>  <riskRecord>
>    <riskRecordSeverity></riskRecordSeverity>
>    <riskRecordDescription></riskRecordDescription>
>    <riskRecordEffectiveDate></riskRecordEffectiveDate>
>
>    <riskRecordResponse>
>      <riskRecordReponseSeverity></riskRecordResponseSeverity>
>      <riskRecordResponseDescription></riskRecordResponseDescription>
>    </riskRecordResponse>
>  <riskRecord>
> </riskRecords>
>
> Also what would be the XSD for this?
>
> All advice most appreciated.
>
> Regards,
>
>
> Adam M.
Well I'd probably have the severity and date as attributes but that seems a 
reasonable layout., use XML date formats (ISO 8601) if at all possible 
(yyyy-MM-ddThh:mm:ss) rather than a local one such as MM/dd/yyyy.
To get a schema start with XSD.EXE. You run it against the xml and it will 
generate a schema. You will need to tweak it, mainly by altering the 
minOccurs and maxOccurs values and picking better data types in some cases.
Then you might possible make the severity an enumeration.

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
date: Sun, 29 Jun 2008 11:04:22 +0100   author:   Joe Fawcett am

Re: XML Design   
Hi,

Thanks for that.

So you would recommend something like:

<riskRecords>
  <riskRecord severity="" effectivedate="">
    <description></description>

    <riskRecordResponse severity="">
      <riskRecordResponseDescription></riskRecordResponseDescription>
    </riskRecordResponse>
  </riskRecord>

Could you tell me why?

Also where do I find this xsd tool?  Can't seem to locate it in my vs2008 
installation?

Thanks.

"Joe Fawcett" <joefawcett@newsgroup.nospam> wrote in message 
news:875EB967-5F5D-4F1D-80DD-6BD19EFD010A@microsoft.com...
>
>
> "Adam David Moss" <no@email.address> wrote in message 
> news:Omc6Agc2IHA.5664@TK2MSFTNGP02.phx.gbl...
>> Hi All,
>>
>> Bit of a newbie when it comes to designing XML layouts so I'm after some 
>> advice.
>>
>> I have a record Risk, which has elements of severity (low, medium, high), 
>> description (string), effective date (date).  Related to that I have 
>> another record, Response, which has the elements of severity (none, low, 
>> medium, high), and description (string).
>>
>> What would be the "ideal" way of laying these out in XML?  Currently I 
>> have:
>>
>> <riskRecords>
>>  <riskRecord>
>>    <riskRecordSeverity></riskRecordSeverity>
>>    <riskRecordDescription></riskRecordDescription>
>>    <riskRecordEffectiveDate></riskRecordEffectiveDate>
>>
>>    <riskRecordResponse>
>>      <riskRecordReponseSeverity></riskRecordResponseSeverity>
>>      <riskRecordResponseDescription></riskRecordResponseDescription>
>>    </riskRecordResponse>
>>  <riskRecord>
>>
>>  <riskRecord>
>>    <riskRecordSeverity></riskRecordSeverity>
>>    <riskRecordDescription></riskRecordDescription>
>>    <riskRecordEffectiveDate></riskRecordEffectiveDate>
>>
>>    <riskRecordResponse>
>>      <riskRecordReponseSeverity></riskRecordResponseSeverity>
>>      <riskRecordResponseDescription></riskRecordResponseDescription>
>>    </riskRecordResponse>
>>  <riskRecord>
>> </riskRecords>
>>
>> Also what would be the XSD for this?
>>
>> All advice most appreciated.
>>
>> Regards,
>>
>>
>> Adam M.
> Well I'd probably have the severity and date as attributes but that seems 
> a reasonable layout., use XML date formats (ISO 8601) if at all possible 
> (yyyy-MM-ddThh:mm:ss) rather than a local one such as MM/dd/yyyy.
> To get a schema start with XSD.EXE. You run it against the xml and it will 
> generate a schema. You will need to tweak it, mainly by altering the 
> minOccurs and maxOccurs values and picking better data types in some 
> cases.
> Then you might possible make the severity an enumeration.
>
> -- 
>
> Joe Fawcett (MVP - XML)
> http://joe.fawcett.name
date: Sun, 29 Jun 2008 13:35:14 +0100   author:   Adam David Moss ess

Re: XML Design   
Adam David Moss wrote:

> Also where do I find this xsd tool?  Can't seem to locate it in my 
> vs2008 installation?

It is a command line tool so open a Visual Studio 2008 Command Prompt, 
then you can use xsd.exe in there from the command line.
Type
xsd.exe /?
to see the possible uses.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Sun, 29 Jun 2008 14:49:32 +0200   author:   Martin Honnen

Re: XML Design   
"Adam David Moss" <no@email.address> wrote in message 
news:#IyIOSe2IHA.2188@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> Thanks for that.
>
> So you would recommend something like:
>
> <riskRecords>
>  <riskRecord severity="" effectivedate="">
>    <description></description>
>
>    <riskRecordResponse severity="">
>      <riskRecordResponseDescription></riskRecordResponseDescription>
>    </riskRecordResponse>
>  </riskRecord>
>
> Could you tell me why?
>
> Also where do I find this xsd tool?  Can't seem to locate it in my vs2008 
> installation?
>
> Thanks.
>
> "Joe Fawcett" <joefawcett@newsgroup.nospam> wrote in message 
> news:875EB967-5F5D-4F1D-80DD-6BD19EFD010A@microsoft.com...
>>
>>
>> "Adam David Moss" <no@email.address> wrote in message 
>> news:Omc6Agc2IHA.5664@TK2MSFTNGP02.phx.gbl...
>>> Hi All,
>>>
>>> Bit of a newbie when it comes to designing XML layouts so I'm after some 
>>> advice.
>>>
>>> I have a record Risk, which has elements of severity (low, medium, 
>>> high), description (string), effective date (date).  Related to that I 
>>> have another record, Response, which has the elements of severity (none, 
>>> low, medium, high), and description (string).
>>>
>>> What would be the "ideal" way of laying these out in XML?  Currently I 
>>> have:
>>>
>>> <riskRecords>
>>>  <riskRecord>
>>>    <riskRecordSeverity></riskRecordSeverity>
>>>    <riskRecordDescription></riskRecordDescription>
>>>    <riskRecordEffectiveDate></riskRecordEffectiveDate>
>>>
>>>    <riskRecordResponse>
>>>      <riskRecordReponseSeverity></riskRecordResponseSeverity>
>>>      <riskRecordResponseDescription></riskRecordResponseDescription>
>>>    </riskRecordResponse>
>>>  <riskRecord>
>>>
>>>  <riskRecord>
>>>    <riskRecordSeverity></riskRecordSeverity>
>>>    <riskRecordDescription></riskRecordDescription>
>>>    <riskRecordEffectiveDate></riskRecordEffectiveDate>
>>>
>>>    <riskRecordResponse>
>>>      <riskRecordReponseSeverity></riskRecordResponseSeverity>
>>>      <riskRecordResponseDescription></riskRecordResponseDescription>
>>>    </riskRecordResponse>
>>>  <riskRecord>
>>> </riskRecords>
>>>
>>> Also what would be the XSD for this?
>>>
>>> All advice most appreciated.
>>>
>>> Regards,
>>>
>>>
>>> Adam M.
>> Well I'd probably have the severity and date as attributes but that seems 
>> a reasonable layout., use XML date formats (ISO 8601) if at all possible 
>> (yyyy-MM-ddThh:mm:ss) rather than a local one such as MM/dd/yyyy.
>> To get a schema start with XSD.EXE. You run it against the xml and it 
>> will generate a schema. You will need to tweak it, mainly by altering the 
>> minOccurs and maxOccurs values and picking better data types in some 
>> cases.
>> Then you might possible make the severity an enumeration.
>>
>> -- 
>>
>> Joe Fawcett (MVP - XML)
>> http://joe.fawcett.name
>
I just think attributes are better for meta-data and single values. The only 
reason that I'd put description as a text node is that long text values are 
unwieldy in attribute values.
It's not something I'd get into a fight over though :)

-- 

Joe Fawcett (MVP - XML)
http://joe.fawcett.name
date: Sun, 29 Jun 2008 16:12:11 +0100   author:   Joe Fawcett am

Re: XML Design   
Joe Fawcett wrote:
> I just think attributes are better for meta-data and single values. The
> only reason that I'd put description as a text node is that long text
> values are unwieldy in attribute values.

I'd agree with Joe (and see
http://xml.silmaril.ie/developers/attributes/). I also favour terseness,
no matter what the Spec suggests :-) I'm really not convinced of the
need to repeat the locus as a prefix on every element type name:
redundancy is all very well, but it makes the file very cluttered.

<risks>
 <risk severity="low" effective="yyyy-mm-dd">
   <description></description>
   <response severity="high">
     <description></description>
   </response>
 <risk>
...
</risks>

This also means you only have to define description once.

> It's not something I'd get into a fight over though :)

No, but it's the kind of thing that leads to long sessions in the pub at
XML conferences :-)

///Peter
date: Sun, 29 Jun 2008 23:23:08 +0100   author:   Peter Flynn

Re: XML Design   
Ok,

So working on the advice so far I've come up with:

<?xml version="1.0" encoding="UTF-8" ?>

<xs:schema elementFormDefault="qualified" 
targetNamespace="http://www.anurl.com" version="1.0" 
xmlns="http://www.anurl.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="risk" type="risksType" />

  <xs:complexType name="risksType">
    <xs:sequence>
      <xs:element name="risk" type="riskType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="riskType">
    <xs:sequence>
      <xs:element name="description" type="xs:string" />
      <xs:element name="response" type="responseType" />
    </xs:sequence>

    <xs:attribute name="severity">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="Low" />
          <xs:enumeration value="Moderate" />
          <xs:enumeration value="Substantial" />
          <xs:enumeration value="Severe" />
          <xs:enumeration value="Critical" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>

    <xs:attribute name="effectiveDate" type="xs:date" />
  </xs:complexType>

  <xs:complexType name="responseType">
    <xs:sequence>
      <xs:element name="description" type="xs:string" />
    </xs:sequence>

    <xs:attribute name="severity">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="Normal" />
          <xs:enumeration value="Heightened" />
          <xs:enumeration value="Exceptional" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>
</xs:schema>

Is this the correct way to lay this out or have I missed something?

Many thanks.


"Peter Flynn"  wrote in message 
news:6cqgadF3fal8pU1@mid.individual.net...
> Joe Fawcett wrote:
>> I just think attributes are better for meta-data and single values. The
>> only reason that I'd put description as a text node is that long text
>> values are unwieldy in attribute values.
>
> I'd agree with Joe (and see
> http://xml.silmaril.ie/developers/attributes/). I also favour terseness,
> no matter what the Spec suggests :-) I'm really not convinced of the
> need to repeat the locus as a prefix on every element type name:
> redundancy is all very well, but it makes the file very cluttered.
>
> <risks>
> <risk severity="low" effective="yyyy-mm-dd">
>   <description></description>
>   <response severity="high">
>     <description></description>
>   </response>
> <risk>
> ...
> </risks>
>
> This also means you only have to define description once.
>
>> It's not something I'd get into a fight over though :)
>
> No, but it's the kind of thing that leads to long sessions in the pub at
> XML conferences :-)
>
> ///Peter
>
date: Mon, 30 Jun 2008 22:30:02 +0100   author:   Adam David Moss ess

Re: XML Design   
That looks okay although schemas are not my strong suit.
I do believe you need minOccurs="0" and maxOccurs="unbounded" on <xs:element 
name="risk" type="riskType" />
(If there must be one risk the you can omit the minOccurs attribute.)

-- 

Joe Fawcett (MVP - XML)

http://joe.fawcett.name


"Adam David Moss" <no@email.address> wrote in message 
news:O$a1shv2IHA.2332@TK2MSFTNGP03.phx.gbl...
> Ok,
>
> So working on the advice so far I've come up with:
>
> <?xml version="1.0" encoding="UTF-8" ?>
>
> <xs:schema elementFormDefault="qualified" 
> targetNamespace="http://www.anurl.com" version="1.0" 
> xmlns="http://www.anurl.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">
>  <xs:element name="risk" type="risksType" />
>
>  <xs:complexType name="risksType">
>    <xs:sequence>
>      <xs:element name="risk" type="riskType" />
>    </xs:sequence>
>  </xs:complexType>
>
>  <xs:complexType name="riskType">
>    <xs:sequence>
>      <xs:element name="description" type="xs:string" />
>      <xs:element name="response" type="responseType" />
>    </xs:sequence>
>
>    <xs:attribute name="severity">
>      <xs:simpleType>
>        <xs:restriction base="xs:string">
>          <xs:enumeration value="Low" />
>          <xs:enumeration value="Moderate" />
>          <xs:enumeration value="Substantial" />
>          <xs:enumeration value="Severe" />
>          <xs:enumeration value="Critical" />
>        </xs:restriction>
>      </xs:simpleType>
>    </xs:attribute>
>
>    <xs:attribute name="effectiveDate" type="xs:date" />
>  </xs:complexType>
>
>  <xs:complexType name="responseType">
>    <xs:sequence>
>      <xs:element name="description" type="xs:string" />
>    </xs:sequence>
>
>    <xs:attribute name="severity">
>      <xs:simpleType>
>        <xs:restriction base="xs:string">
>          <xs:enumeration value="Normal" />
>          <xs:enumeration value="Heightened" />
>          <xs:enumeration value="Exceptional" />
>        </xs:restriction>
>      </xs:simpleType>
>    </xs:attribute>
>  </xs:complexType>
> </xs:schema>
>
> Is this the correct way to lay this out or have I missed something?
>
> Many thanks.
>
>
> "Peter Flynn"  wrote in message 
> news:6cqgadF3fal8pU1@mid.individual.net...
>> Joe Fawcett wrote:
>>> I just think attributes are better for meta-data and single values. The
>>> only reason that I'd put description as a text node is that long text
>>> values are unwieldy in attribute values.
>>
>> I'd agree with Joe (and see
>> http://xml.silmaril.ie/developers/attributes/). I also favour terseness,
>> no matter what the Spec suggests :-) I'm really not convinced of the
>> need to repeat the locus as a prefix on every element type name:
>> redundancy is all very well, but it makes the file very cluttered.
>>
>> <risks>
>> <risk severity="low" effective="yyyy-mm-dd">
>>   <description></description>
>>   <response severity="high">
>>     <description></description>
>>   </response>
>> <risk>
>> ...
>> </risks>
>>
>> This also means you only have to define description once.
>>
>>> It's not something I'd get into a fight over though :)
>>
>> No, but it's the kind of thing that leads to long sessions in the pub at
>> XML conferences :-)
>>
>> ///Peter
>>
>
date: Tue, 1 Jul 2008 09:44:39 +0100   author:   Joe Fawcett am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us