Permalink
Browse files

FIX: Fixed formatting errors in document (again...)

  • Loading branch information...
1 parent ffd6e6a commit d7b9aaecc51841a0cc72f5ecb60147296bc91725 Michael Harrison committed Sep 6, 2011
Showing with 15 additions and 44 deletions.
  1. +15 −44 README.textile
View
@@ -1,8 +1,6 @@
h1. XML Active
-Rails has some really fantastic features for serialisation of ActiveRecord to XML however going back the other way is
-not so fantastic. XML Active aims to provide the import of XML into your database while utilising the strengths of
-ActiveRecord. It extends ActiveRecord allowing it to seamlessly work in with your model. Here are the features provided by XML Active:
+Rails has some really fantastic features for serialisation of ActiveRecord to XML however going back the other way is not so fantastic. XML Active aims to provide the import of XML into your database while utilising the strengths of ActiveRecord. It extends ActiveRecord allowing it to seamlessly work in with your model. Here are the features provided by XML Active:
* Updating of records based on an XML document containing elements matching primary key
* Creation of records based on elements in an XML
@@ -11,17 +9,14 @@ ActiveRecord. It extends ActiveRecord allowing it to seamlessly work in with you
* Choose to combine update, create and remove actions
* Synchronise your database with an XML Document
-h2 The Background
+h2. The Background
h3. XML Documents
-XML Active relies on the XML documents created by ActiveRecord in that it utilises the element attributes and document
-layout. Following is a sample of an XML document. Note the @type@ attribute which helps to identify elements that are
-integers, arrays, etc.
+XML Active relies on the XML documents created by ActiveRecord in that it utilises the element attributes and document layout. Following is a sample of an XML document. Note the @type@ attribute which helps to identify elements that are integers, arrays, etc.
<pre>
<code>
-
<?xml version="1.0" encoding="UTF-8"?>
<books type="array">
<book>
@@ -88,22 +83,16 @@ integers, arrays, etc.
<name>Book 1</name>
</book>
</books>
-
</code>
</pre>
h3. Database Schema
-XML Active will detect the primary key of the tables in your schema even if is a name other than @id@. It will use the
-primary key to match records for update or deletion or creation when they don't exist. Given this it's very important
-that the tables that you wish to synchronise have a primary key with auto increment. The good news is by default Rails
-will create a primary key field called @id@ that is auto-increment. At this time XML Active doesn't support compound
-primary keys.
+XML Active will detect the primary key of the tables in your schema even if is a name other than @id@. It will use the primary key to match records for update or deletion or creation when they don't exist. Given this it's very important that the tables that you wish to synchronise have a primary key with auto increment. The good news is by default Rails will create a primary key field called @id@ that is auto-increment. At this time XML Active doesn't support compound primary keys.
h3. The Model
-In order to identify the relationships XML Active it relies on associations so you have to make sure you define your
-associations in your model. Following are is a sample model.
+In order to identify the relationships XML Active it relies on associations so you have to make sure you define your associations in your model. Following are is a sample model.
@book.rb@
<pre>
@@ -127,26 +116,21 @@ end</code>
end</code>
</pre>
-At this stage XML Active has been tested with a limited number of associations. It is hoped in the future (and when I
-find some more time) that a more complete set of tests will exist.
+At this stage XML Active has been tested with a limited number of associations. It is hoped in the future that a more complete set of tests will exist.
h2. Examples
-Now to the meaty part, the examples. XML Active currenly uses "Nokogiri":http://nokogiri.org/ to do its XML parsing so
-you can provide either a @Nokogiri::XML::Element@ or raw XML.
+Now to the meaty part, the examples. XML Active currenly uses "Nokogiri":http://nokogiri.org/ to do its XML parsing so you can provide either a @Nokogiri::XML::Element@ or raw XML.
h3. New Functions
XML Active extends the ActiveRecord class giving you the following functions:
@many_from_xml(xml, options)@
-Allows for the import of many records based on an XML document. This function expects an XML document similar
-to the following with many records in it:
-
+Allows for the import of many records based on an XML document. This function expects an XML document similar to the following with many records in it:
@books_changed.xml@
<pre>
<code>
-
<?xml version="1.0" encoding="UTF-8"?>
<books type="array">
<book>
@@ -162,7 +146,6 @@ to the following with many records in it:
<name>Book 1</name>
</book>
</books>
-
</code>
</pre>
@@ -172,19 +155,16 @@ Following is an example:
</pre>
@one_from_xml(xml, options)@
-Allows for the import of one record based on an XML document. This function expects an XML document similar
-to the following with many records in it:
+Allows for the import of one record based on an XML document. This function expects an XML document similar to the following with many records in it:
@one_book_changed.xml@
<pre>
<code>
-
<?xml version="1.0" encoding="UTF-8"?>
<book>
<id type="Integer">4</id>
<name>Book 1</name>
</book>
-
</code>
</pre>
@@ -195,22 +175,13 @@ Following is an example:
h3. Options
-You can combine any of the options (:create, :update or :destroy) and XML Active will only perform the actions provided
-in the options. However if you use the :sync option then all other options are ignored. Following are the current
-options:
+You can combine any of the options (:create, :update or :destroy) and XML Active will only perform the actions provided in the options. However if you use the :sync option then all other options are ignored. Following are the current options:
+
+* @:update@ records in the database that match those in the provided XML document based on classes in the model, associations and the primary key.
-* *:update*
-Update records in the database that match those in the provided XML document based on classes in the model, associations
-and the primary key.
+* @:create@ records in the database that exist in the provided XML document but not in the database. Matching is based on classes in the model, associations and the primary key.
-* *:create*
-Create records in the database that exist in the provided XML document but not in the database. Matching is based on
-classes in the model, associations and the primary key.
+* @:destroy@ records in the database that don't exist in the provided XML document. Matching is based on classes in the model, associations and the primary key. This respects validation by using the ActiveRecord destroy rather than delete.
-* *:destroy*
-Destroy records in the database that don't exist in the provided XML document. Matching is based on classes in the
-model, associations and the primary key. This respects validation by using the ActiveRecord destroy rather than delete.ß
+* @:sync@ is really the combination of :create, :update and :destroy. Using this option will cause XML Active to ignore :create, :update and :destroy options and will proceed to make your database records match those in the XML document.
-* *:sync*
-This is really the combination of :create, :update and :destroy. Using this option will cause XML Active to ignore
-:create, :update and :destroy options and will proceed to make your database records match those in the XML document.

0 comments on commit d7b9aae

Please sign in to comment.