Previous | Next
WireHose Developers Guide

XML mapping model

Mapping models are used to translate XML data to objects. For importing new resources into the database, the convention is to map the XML data to an array of NSDictionary objects which represent snapshots of the individual items. For more information about mapping models, see the WebObjects documentation.

  1. Expand the Resources group in the Files pane.
  2. Choose Add Files... from Project menu.
  3. Select rss20MappingModel.xml in the WireHoseExtras/SampleData/maps/ folder, and click Add.
  4. Check "Copy items into destination group's folder (if needed)", add it to the Application Server target, and click Add.

Here's what the mapping model looks like. This mapping model specifies all the attributes in an RSS 2.0 file, including the ones Hello World is ignoring. The attributes used by Hello World are highlighted.

<?xml version="1.0" encoding="iso-8859-1"?>
<model>
    <entity name="NSMutableDictionary" xmlTag="rss" unmappedTagsKey="unmappedTags">
        <property name="channel" xmlTag="channel"/>
        <property name="version" xmlTag="version"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="channel" unmappedTagsKey="unmappedTags" >
        <property name="name" xmlTag="title"/>
        <property name="link" xmlTag="link"/>
        <property name="textDescription" xmlTag="description"/>
        <property name="language" xmlTag="language"/>
        <property name="copyright" xmlTag="copyright"/>
        <property name="managingEditor" xmlTag="managingEditor"/>
        <property name="webMaster" xmlTag="webMaster"/>
        <property name="pubDate" xmlTag="pubDate"/>
        <property name="lastBuildDate" xmlTag="lastBuildDate"/>
        <property name="tags" xmlTag="category" forceList="YES"/>
        <property name="generator" xmlTag="generator"/>
        <property name="docs" xmlTag="docs"/>
        <property name="cloud" xmlTag="cloud"/>
        <property name="ttl" xmlTag="ttl"/>
        <property name="image" xmlTag="image"/>
        <property name="rating" xmlTag="rating"/>
        <property name="textInput" xmlTag="textInput"/>
        <property name="skipHours" xmlTag="skipHours"/>
        <property name="skipDays" xmlTag="skipDays"/>
        <property name="items" xmlTag="item" forceList="YES"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="image" unmappedTagsKey="unmappedTags">
        <property name="url" xmlTag="url"/>
        <property name="title" xmlTag="title"/>
        <property name="link" xmlTag="link"/>
        <property name="width" xmlTag="width"/>
        <property name="height" xmlTag="height"/>
        <property name="description" xmlTag="description"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="cloud" unmappedTagsKey="unmappedTags">
        <property name="domain" xmlTag="domain"/>
        <property name="port" xmlTag="port"/>
        <property name="registerProcedure" xmlTag="registerProcedure"/>
        <property name="protocol" xmlTag="protocol"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="textInput" unmappedTagsKey="unmappedTags">
        <property name="title" xmlTag="title"/>
        <property name="description" xmlTag="description"/>
        <property name="name" xmlTag="name"/>
        <property name="link" xmlTag="link"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="item" unmappedTagsKey="unmappedTags">
        <property name="name" xmlTag="title"/>
        <property name="link" xmlTag="link"/>
        <property name="textDescription" xmlTag="description"/>
        <property name="author" xmlTag="author"/>
        <property name="tags" xmlTag="category" forceList="YES"/>
        <property name="comments" xmlTag="comments"/>
        <property name="enclosure" xmlTag="enclosure"/>
        <property name="guid" xmlTag="guid"/>
        <property name="pubDate" xmlTag="pubDate"/>
        <property name="source" xmlTag="source"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="source" unmappedTagsKey="unmappedTags" contentsKey="description">
        <property name="description" xmlTag="description"/>
        <property name="url" xmlTag="url"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="enclosure" unmappedTagsKey="unmappedTags">
        <property name="url" xmlTag="url"/>
        <property name="length" xmlTag="length"/>
        <property name="type" xmlTag="type"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="category" unmappedTagsKey="unmappedTags" contentsKey="id">
        <property name="id" xmlTag="id"/>
        <property name="domain" xmlTag="domain"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="guid" unmappedTagsKey="unmappedTags" contentsKey="id">
        <property name="id" xmlTag="id"/>
        <property name="isPermaLink" xmlTag="isPermaLink"/>
    </entity>
    <entity name="NSMutableDictionary" xmlTag="enclosure" unmappedTagsKey="unmappedTags">
        <property name="title" xmlTag="title"/>
        <property name="description" xmlTag="description"/>
        <property name="name" xmlTag="name"/>
        <property name="link" xmlTag="link"/>
    </entity>
</model>

Previous | Next