5 Replies Latest reply on Nov 26, 2006 10:11 AM by EL11

    cfxml rearranges elements?

    EL11
      <cfxml variable="xmlObject" casesensitive="yes">
      <gallery>
      <album title="Product Detail">
      <cfoutput query="rsImageFiles">
      <img src = " http://www.testing.com/Images/Products/#rsImageFiles.Name#" caption = "Flat View" />
      </cfoutput>
      </album>
      </gallery>
      </cfxml>

      creates this xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <gallery>
      <album title="Product Detail">
      <img caption="Flat View" src=" http://www.testing.com/Images/Products/B1004Back.jpg"/>
      <img caption="Flat View" src=" http://www.testing.com/Images/Products/B1004Full.jpg"/>
      <img caption="Flat View" src=" http://www.testing.com/Images/Products/B1004Main.jpg"/>
      <img caption="Flat View" src=" http://www.testing.com/Images/Products/B1004Thumb.jpg"/>
      </album>
      </gallery>

      The elements 'src' and 'caption' have been rearranged. Any way to avoid this?
        • 1. Re: cfxml rearranges elements?
          Level 7
          I can confirm I see this too. I tried to get around it by using
          <cfsavecontent> instead, but as soon as I xmlParse() it, the attibutes are
          swapping. It seems they're being ordered alphabetically. Stupid thing for
          CF to be doing.

          Pls note that relying on the ordering of the attributes conflicts with the
          spec of XML: attributes have no sense of ordering (same as struct keys have
          no sense of ordering).

          Not sure how to get around it though, I'm afraid. I've raised it as a bug,
          because whilst there should be no sense of order, I don't think CF should
          be going out of its way to CHANGE the ordering. It should certainly not be
          SORTING them.

          PS: Adobe's bug reporting is a black hole: no reference number is returned
          after submission, so there's no way for anyone to track the issue once
          submitted. Or even any way of knowing they actually pay any attention to
          the issues at all.

          --
          Adam
          • 2. Re: cfxml rearranges elements?
            EL11 Level 1
            Unfortunately the sequence of the elements is crucial for the component I am creating this for: SlideShowPro ( http://www.slideshowpro.net/product_ssp.php).

            They do not recognize the 'caption' element unless its after the 'src' element.
            • 3. Re: cfxml rearranges elements?
              Level 7
              > Unfortunately the sequence of the elements is crucial for the component I am
              > creating this for: SlideShowPro ( http://www.slideshowpro.net/product_ssp.php).
              >
              > They do not recognize the 'caption' element unless its after the 'src' element.

              I'd drop them a line and point this situation out to them, then. They are
              misusing XML.

              Having said that, how are you passing the XML to this thing? XML is just a
              string... you don't need to use CF's XML functions to build the XML.
              <cfsavecontent> does not mung the XML; it's only when one runs it through
              xmlPrae() that CF buggers about with it. But there's probably no need to
              XML parse it: an external system will expect a string, not a CF-XML-object.

              --
              Adam
              • 4. Re: cfxml rearranges elements?
                cfjedimaster Level 3
                Any possibility you could log a bug report with SlideShowPro? Seems like their product shouldn't throw an error in a case like this.
                • 5. Re: cfxml rearranges elements?
                  EL11 Level 1
                  Good point. I could just create a text file. Looks like thats what I'll have to do.