Announcement

Collapse
No announcement yet.

XML Data formatting question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XML Data formatting question

    Given these two XML snippets (yes I know not they are not valid as it stands) which one is considered "standard practice"

    Long Version

    Code:
     
    <SecurityGroups>
      <SecurityGroup>
        <GroupName>Administrators</GroupName> 
        <GroupMembers>
          <MemberName>LocalMachineName\Administrator</MemberName> 
          <MemberName>DomainName\Domain Admins</MemberName> 
        </GroupMembers>
      </SecurityGroup>
      <SecurityGroup>
        <GroupName>Users</GroupName> 
        <GroupMembers>
          <MemberName>DomainName\Domain Users</MemberName> 
        </GroupMembers>
      </SecurityGroup>
    <SecurityGroups>
    Short Version

    Code:
     
    <SecurityGroups>
      <SecurityGroup Name="Administrators"> 
        <MemberName>LocalMachineName\Administrator</MemberName> 
        <MemberName>DomainName\Domain Admins</MemberName> 
      </SecurityGroup>
      <SecurityGroup Name="Users"> 
        <MemberName>DomainName\Domain Users</MemberName> 
      </SecurityGroup>
    </SecurityGroups>
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

  • #2
    Interestingly, MSAccess2003 Exports the data in this format... a 3rd option.

    Code:
     
    <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2009-08-19T15:26:45">
      <SecurityGroup>
        <GroupName>Administrators</GroupName> 
        <MemberName>HIX-DSDV5\Administrator</MemberName> 
      </SecurityGroup>
      <SecurityGroup>
        <GroupName>Administrators</GroupName> 
        <MemberName>KEYSPANENERGY\Domain Admins</MemberName> 
      </SecurityGroup>
      <SecurityGroup>
        <GroupName>Users</GroupName> 
        <MemberName>KEYSPANENERGY\Domain Users</MemberName> 
      </SecurityGroup>
    </dataroot>
    Last edited by George Bleck; 19 Aug 2009, 02:27 PM.
    <b>George W. Bleck</b>
    <img src='http://www.blecktech.com/myemail.gif'>

    Comment


    • #3
      I'd go for your second example in your first post (group name as an attribute instead of a own node), because I could retrieve a complete security group node with one XPath query, whereas for the other two examples, I would have to walk nodes to find the desired security group.

      Comment


      • #4
        One of the benefits of using XML is that there is no "standard practice". You can format the data whatever way you want. That being said, I'm with Knuth, and think your second example is set up the easiest for dealing with the data.
        Jeff Blakeney

        Comment


        • #5
          >One of the benefits of using XML is that there is no "standard practice".

          Some might consider that a drawback.

          MCM
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            I can save you a lot problems in this matter as I have just spent 6 months riping my hair out on this very matter. Use the first version ! The embedded attributes cause nothing but problems as some parsers can't handle the embedded attributes in normal parsing. So you end up having to write one version for type 1 and and another for type 2 to specially handle the attributes. I my case I end up with six version because there is real standard.

            The whole idea of xml was to describe data so you did not need to know the data structure. Nooooooo !
            Last edited by Martin Draper; 25 Aug 2009, 12:53 AM.

            Comment


            • #7
              The whole idea of xml was to describe data so you did not need to know the data structure. Nooooooo
              Well, that's true, but the DTD specs were designed to allow for "dynamic" definition of the data.

              However, dynamic data description and 'roll-your-own' formatting is simply not a a good solution for the commercial environment.

              I've been working with ANSI ASC X12 and EDIFACT format data for 25+ years. Both these formats are also 'self-describing' but in Real Life everything depends on the partners' agreement as to what all the data elements mean.

              There have been many, many threads over the years on the EDI-L listserve (now hosted by Google Groups) about how "XML Format" is going to totally replace ANSI ASC X12 format. IIRC the first such 'guarantee' was made in 1993 or so.

              But I still get most of my food, clothing and shelter from ANSI/EDIFACT and next to none from XML.

              MCM
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Originally posted by Martin Draper View Post
                The embedded attributes cause nothing but problems as some parsers can't handle the embedded attributes in normal parsing.
                Well, if I were you, my first reaction would've been: "Get a working parser!"

                If they insist on using a faulty parser (more likely: they don't know how to use the parser), you could do a combination of 1 and 2:

                Code:
                <SecurityGroups>
                  <SecurityGroup name="Administrators">
                    <GroupName>Administrators</GroupName> 
                    <GroupMembers>
                      <MemberName>LocalMachineName\Administrator</MemberName> 
                      <MemberName>DomainName\Domain Admins</MemberName> 
                    </GroupMembers>
                  </SecurityGroup>
                  <SecurityGroup name="Users">
                    <GroupName>Users</GroupName> 
                    <GroupMembers>
                      <MemberName>DomainName\Domain Users</MemberName> 
                    </GroupMembers>
                  </SecurityGroup>
                <SecurityGroups>

                Comment

                Working...
                X