xml structure question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andy

    xml structure question

    say i currently have xml like so...

    <node>
    <Date>2008050 7</Date>
    <ChildNode />
    <ChildNode />
    </node>
    <node>
    <Date>2008050 7</Date>
    <ChildNode />
    <ChildNode />
    </node>
    etc...

    And I know that later i want to group by the date (either using xslt or
    after importing the xml data into another format)

    would it be better to have the date as the master node ?, like for
    example...

    <Date date="20080507" >
    <node>
    <ChildNode />
    <ChildNode />
    </node>
    <node>
    <ChildNode />
    <ChildNode />
    </node>
    </Date>

    Are there any good guides on how and why to structure xml documents ?

    any help appreciated.

    --
    Eps
  • Joseph J. Kesselman

    #2
    Re: xml structure question

    Are there any good guides on how and why to structure xml documents ?

    It's very much like constructing data structures in programming
    languages or databases; most of the same best-practices apply.
    In general, you should structure to capture the semantics (meaning) that
    your data is intended to express, and/or tune it to suit the most common
    usage... and sometimes, especially early on, to make most sense to the
    human trying to debug the system.

    Note that converting between these two ways of organizing the data isn't
    hard. Lots of examples exist.

    Comment

    • andy

      #3
      Re: xml structure question

      Joseph J. Kesselman wrote:
      >Are there any good guides on how and why to structure xml documents ?
      >
      It's very much like constructing data structures in programming
      languages or databases; most of the same best-practices apply.
      In general, you should structure to capture the semantics (meaning) that
      your data is intended to express, and/or tune it to suit the most common
      usage... and sometimes, especially early on, to make most sense to the
      human trying to debug the system.
      >
      Note that converting between these two ways of organizing the data isn't
      hard. Lots of examples exist.
      your right, I was a little vague.

      Lets say I want to create a xsl file to go with the xml file that will
      group the data by date, perhaps even have some funky java script that
      will group data by one of the child nodes as well

      <node>
      <Date>2008050 7</Date>
      <Pattern>patter n1</Pattern>
      <ChildNode />
      </node>
      <node>
      <Date>2008050 7</Date>
      <Pattern>patter n1</Pattern>
      <ChildNode />
      </node>

      then the resulting html document would look something like


      20080507

      +patern1 // this will be clickable and collapsable, when expanded you
      can see all the data for the child nodes which


      any help appreciated.

      --
      Eps

      Comment

      • Joseph J. Kesselman

        #4
        Re: xml structure question

        You can work from either representation. (One of XSLT's advantages over
        CSS is that the output document's structure can be completely different
        from that of the input.) The question is one of how you're generating
        the document and what else you're doing with it. There are certainly
        some forms which will be easier for this particular XSLT stylesheet to
        process, but they may not be easier for your other needs. Beware of
        optimizing for only one case.

        If your stylesheet needs to gather things with the same date, you might
        want to examine the "grouping" section of the XSLT FAQ:



        Comment

        • Peter Flynn

          #5
          Re: xml structure question

          andy wrote:
          Are there any good guides on how and why to structure xml documents ?
          There is a lot of excellent stuff about this in Eve Maler and Jeanne El
          Andaloussi's book "Writing SGML DTDs" (95% of which remains valid for
          XML: just ignore the SGL bits).

          ///Peter
          --
          XML FAQ: http://xml.silmaril.ie/

          Comment

          • andy

            #6
            Re: xml structure question

            Joseph J. Kesselman wrote:
            You can work from either representation. (One of XSLT's advantages over
            CSS is that the output document's structure can be completely different
            from that of the input.) The question is one of how you're generating
            the document and what else you're doing with it. There are certainly
            some forms which will be easier for this particular XSLT stylesheet to
            process, but they may not be easier for your other needs. Beware of
            optimizing for only one case.
            >
            If your stylesheet needs to gather things with the same date, you might
            want to examine the "grouping" section of the XSLT FAQ:
            >

            >
            Thanks for your replies. I guess I was looking to try and make it so
            the javascript is as easy to write as possible, your advice has been
            very helpful.

            --
            Eps

            Comment

            • Joseph J. Kesselman

              #7
              Re: xml structure question

              andy wrote:
              Thanks for your replies. I guess I was looking to try and make it so
              the javascript is as easy to write as possible
              That's as reasonable a primary design goal as any other. It's up to you
              to decide whether that's the right thing to optimize for.

              As with any programming problem, there are multiple solutions that work.
              Which one's best depends on what's most important to you.

              My personal inclination would be to start with the first approach, where
              each record carries its own date, and to generate the gathered-by-date
              version from that if/when needed. But that assumes the nodes, rather
              than the dates, are the thing you consider your most basic unit of
              information. For other applications, the Date may really be the primary
              chunk of data and the second approach would be better.

              Comment

              Working...