diff -r 322d0feea350 -r 89ef5ed3c48b src/cm/media/js/lib/yui/yui_3.10.3/docs/dataschema/dataschema-text.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.10.3/docs/dataschema/dataschema-text.html Tue Jul 16 14:29:46 2013 +0200 @@ -0,0 +1,259 @@ + + + + + Example: DataSchema.Text + + + + + + + + + + +
+
+

+
+ + +

Example: DataSchema.Text

+
+
+
+
+

DataSource.Text normalizes delimited text data against a given schema into an object with known properties.

+
+ +
+ + +
+
Data
+
+notebooks, 100, spiral-bound
+pencils, 300, #2 with erasers
+pens, 500, blue ink
+    
+ +
Schema
+
+{
+    resultDelimiter: "\n",
+    fieldDelimiter: ",",
+    resultFields: [{key:"product"}, {key:"quantity"}, {key:"detail"}]
+}
+    
+ +
Normalized data
+ +
+
+ + + +
+ +

In order to use DataSchema.Text, input data must be delimited text. Define as your schema's resultDelimiter property the string that separates each result, and define as your schema's fieldDelimiter property the string that separates each field of each result.

+ +
YUI().use("dataschema-text", function(Y) {
+    var data_in = "notebooks, 100, spiral-bound\\npencils, 300, #2 with erasers\\npens, 500, blue ink",
+        schema = {
+            resultDelimiter: "\\n",
+            fieldDelimiter: ",",
+            // Or simply: ["product", "quantity", "detail"]
+            resultFields: [{key:"product"}, {key:"quantity"}, {key:"detail"}]
+        },
+        data_out = Y.DataSchema.Text.apply(schema, data_in));
+
+    alert(data_out);
+});
+ +
+
+
+ +
+ +
+
+
+ + + + + + + + + + +