[Practicalxml-commits] SF.net SVN: practicalxml:[142] branches/dev-1.1/src/main/java/net/sf/ practi
Brought to you by:
kdgregory
From: Auto-Generated S. C. M. <pra...@li...> - 2009-09-22 15:05:43
|
Revision: 142 http://practicalxml.svn.sourceforge.net/practicalxml/?rev=142&view=rev Author: kdgregory Date: 2009-09-22 15:05:25 +0000 (Tue, 22 Sep 2009) Log Message: ----------- add conversion options, package docs Added Paths: ----------- branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Json2XmlOptions.java branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Xml2JsonOptions.java branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/package.html Added: branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Json2XmlOptions.java =================================================================== --- branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Json2XmlOptions.java (rev 0) +++ branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Json2XmlOptions.java 2009-09-22 15:05:25 UTC (rev 142) @@ -0,0 +1,31 @@ +// Copyright 2008-2009 severally by the contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package net.sf.practicalxml.converter.json; + + +/** + * Options to control conversion from JSON strings to XML documents. + */ +public enum Json2XmlOptions +{ + /** + * Convert JSON arrays to repeated XML elements with the same name. + * Default behavior is to create a parent-children construct, in which + * the parent has the given element name, while each child is named + * "data" (this approach can be subsequently passed to the XML->Java + * converter). + */ + ARRAYS_AS_REPEATED_ELEMENTS +} Added: branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Xml2JsonOptions.java =================================================================== --- branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Xml2JsonOptions.java (rev 0) +++ branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/Xml2JsonOptions.java 2009-09-22 15:05:25 UTC (rev 142) @@ -0,0 +1,29 @@ +// Copyright 2008-2009 severally by the contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package net.sf.practicalxml.converter.json; + + +/** + * Options to control conversion from XML documents to JSON strings + */ +public enum Xml2JsonOptions +{ + /** + * Examines the XML element for an <code>xsi:type</code> attribute; if + * present, will only quote-delimit character data (<code>xsd:string</code>, + * <code>xsd:char</code>, and the like). + */ + USE_XSI_TYPE +} Added: branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/package.html =================================================================== --- branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/package.html (rev 0) +++ branches/dev-1.1/src/main/java/net/sf/practicalxml/converter/json/package.html 2009-09-22 15:05:25 UTC (rev 142) @@ -0,0 +1,38 @@ +<html> +<body> + +This package contains classes to convert JSON (JavaScript Object Notation) +strings (as defined <a href="http://www.json.org/">json.org</a> ) to and +from an XML DOM. Although both XML and JSON are textual representations of +hierarchical data, there are some peculiarities in the conversion: + +<dl> +<dt> Container Element +<dd> Although elements within a JSON object are named, the object itself is + not. XML requires a named root element, so the JSON->XML conversion + creates a root element named "data", and the XML->JSON conversion ignores + the passed root element. +<dt> Document Order +<dd> In XML, document order is important and may be validated; in JSON, the + order of elements within an object is not important. To support arrays + (qv), the XML->JSON conversion intentionally breaks document order. And + as JSON has no intrinsic order, you'll need to explicitly re-arrange the + result of a JSON->XML conversion prior to any validation. +<dt> Non-String Data +<dd> JSON supports numbers and boolean literals in addition to quote-delimited + strings. The JSON->XML conversion will handle these values transparently. + The default XML->JSON conversion writes all content as quote-delimited + strings, but there is a conversion option to recognize a limited set of + non-string elements based on the <code>xsi:type</code> attribute. +<dt> Arrays +<dd> XML does not have a defined array construct, but may repeat elements; JSON + has a defined array construct, and repeated elements will overwrite the + former definition. To avoid this problem, the XML->JSON conversion will + identify all repeated elements and create an array construct. The default + JSON->XML conversion creates a parent-children construct (which is more + palatable to subsequent XML->Java conversion), but a conversion option + allows conversion to a repeated element. +</dl> + +</body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |