Loading ...
Sorry, an error occurred while loading the content.

Re: DataSource XML Schema - XML Object?

Expand Messages
  • Luke
    Support for nested field schemas was just added to DataSchema.XML the other day. Have a look on github for the updated module.
    Message 1 of 2 , Dec 3, 2009
    • 0 Attachment
      Support for nested field schemas was just added to DataSchema.XML the other day.  Have a look on github for the updated module.
      http://github.com/yui/yui3/blob/master/build/dataschema/dataschema-xml.js

      In your case, the comments field def in your resultFields array would look like this:
      {
          key: "comments",
          schema: {
              resultsListLocator: "comments/CommentDo",
              resultFields: [
                  {key: 'id', locator: 'commentID'},
                  ...
              ]
          }
      }

      Hope this helps,
      Luke

      --- In ydn-javascript@yahoogroups.com, "athies" <athies@...> wrote:
      >
      > I am using YUI3 DataSource to pull in some XML. Everything works great except I have a comments section of the returned XML that contains an arbitrary number of comment objects within it. I can't figure out how to pull this comments section out into a usable object, as opposed to a string.
      >
      > Here is my DataSource schema:
      >
      > myDataSourceXML.plug(Y.Plugin.DataSourceXMLSchema, {
      > schema: {
      > resultListLocator: "MediaDo",
      > resultFields: [
      > {key:"mediaID", locator:"*[local-name() ='mediaID']"},
      > {key:"title", locator:"*[local-name() ='title']"},
      > {key:"originalUrl", locator:"*[local-name() ='originalUrl']"},
      > {key:"desc", locator:"*[local-name() ='description']"},
      > {key:"creator", locator:"*[local-name() ='creatorNickName']"},
      > {key:"posted", locator:"*[local-name() ='creationDate']"},
      > {key:"height", locator:"images/ImageDo[type='or']/height"},
      > {key:"width", locator:"images/ImageDo[type='or']/width"},
      > {key:"size", locator:"images/ImageDo[type='or']/size"},
      > {key:"comments", locator:"comments"}
      > ]
      > }
      >
      > Here is what the XML for comments looks like:
      >
      > <comments>
      > <CommentDo>
      > <canEdit>false</canEdit>
      > <comment>volcano comment 2</comment>
      > <commentID>814511802</commentID>
      > <creationDate>1259542360000</creationDate>
      > <creatorNickName>athiesv3</creatorNickName>
      > <creatorYUID>athiesv3#jb</creatorYUID>
      > <domainID>0</domainID>
      > <flag/>
      > <groupID>0</groupID>
      > <mediaID>0</mediaID>
      > <parentID/>
      > <rootID/>
      > </CommentDo>
      > <CommentDo>
      > <canEdit>false</canEdit>
      > <comment>volcano comment 1</comment>
      > <commentID>729126005</commentID>
      > <creationDate>1259542350000</creationDate>
      > <creatorNickName>athiesv3</creatorNickName>
      > <creatorYUID>athiesv3#jb</creatorYUID>
      > <domainID>0</domainID>
      > <flag/>
      > <groupID>0</groupID>
      > <mediaID>0</mediaID>
      > <parentID/>
      > <rootID/>
      > </CommentDo>
      > </comments>
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.