XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] XML and JSON together

I guess I don't like it as a hack, it is sort of akin to the same
thing that people do when their security filters don't allow them to
send .zip files, they rename the file with a .zzz or similar extension
and then send that. If your validation is too restrictive change the
validation, furthermore I don't like it because I think it attacks the
problem from the wrong position.

 Assume you have a document with elements in the 'a' namespace, any
other namespace will be invalid, if you want to be able to send XML
with non-valid structure due to extension needs you could instead of
running a transform to expand JSON run a transform to remove all
elements in other namespaces than the 'a' namespace, or, more to the
point run a transform to extract all namespaces not in the 'a'
namespace and serialize them as their own xml instances (probably
writing rules specific to serialization of specific namespaces found)



Cheers,
Bryan Rasmussen


On Tue, Apr 8, 2008 at 12:57 AM, Robert Koberg <rob@koberg.com> wrote:
> Hi,
>
>  Here is an odd idea I am currently playing around with. I know it is a
>  hack, but what do you think?
>
>  The idea is to use JSON to extend legacy XML instance documents while
>  maintaining original validity. For example, I have some hibernate
>  mapping documents that use the well defined DTD. I want to extend the
>  XML syntax to allow for other concerns in the mapping document which
>  will be used to generate out to multiple concerns.
>
>  With the hibernate mapping document (snippet) below I generate out a
>  java interface, a default implementation, a java 'GET' validator, a java
>  'POST' validator and a java 'POST' persistor. I can do all of that with
>  the standard mappings. But I also want to generate out a useable UI in
>  HTML. I can't do that from the standard mapping. So, I am using JSON to
>  augment the syntax while maintaining validity.
>
>  I run the mapping document through a very simple XSL 2.0 transformation
>  (even further below) that uses Dmitre Novatchev's FXSL library and
>  specifically the json-document function to create an intermediary XML
>  that is then used to generate the HTML for the form.
>
>  Here is a snippet of the mapping document:
>
>  <property column="MARRIED" length="1" name="married" not-null="true"
>  type="boolean">
>   <meta attribute="ui"><![CDATA[{
>     "uses": "focusObject",
>     "row": 1,
>     "region": "wide",
>     "legend": "Marital Status",
>     "err-msg": "Please select your marital status.",
>     "as": "radioGroup",
>     "items": {
>         "radio": {
>           "id": "marriedYes",
>           "value": true,
>           "label": "Married"
>         },
>         "radio": {
>           "id": "marriedNo",
>           "value": false,
>           "label": "Single",
>           "default": true,
>           "event": {
>             "type": "click",
>             "handler": {
>               "name": "toggle",
>               "args": {
>                 "container-idref": "domPartnerInfoCont"
>               }
>             }
>           }
>         }
>       }
>     }
>   }]]></meta>
>  </property>
>  <property column="DOMESTIC_PARTNER_INFO" name="domPartnerInfo"
>  not-null="true" type="boolean">
>   <meta attribute="ui"><![CDATA[{
>     "uses": "focusObject",
>     "row": 1,
>     "region": "wide",
>     "container-id": "domPartnerInfoCont",
>     "label": "Display Domestic Partner information?",
>     "as": "checkbox"
>   }]]></meta>
>  </property>
>
>  Running it through the json to xml transform produces:
>
>  <hibernate-ui>
>   <group column="MARRIED" length="1" name="married" not-null="true"
>  type="boolean"
>     unique="false"
>     optimistic-lock="true"
>     lazy="false"
>     generated="never">
>     <uses>focusObject</uses>
>     <row>1</row>
>     <region>wide</region>
>     <legend>Marital Status</legend>
>     <err-msg>Please select your marital status.</err-msg>
>     <as>radioGroup</as>
>     <items>
>       <radio>
>         <id>marriedYes</id>
>         <value>true</value>
>         <label>Married</label>
>       </radio>
>       <radio>
>         <id>marriedNo</id>
>         <value>false</value>
>         <label>Single</label>
>         <default>true</default>
>         <event>
>           <type>click</type>
>           <handler>
>             <name>toggle</name>
>             <args>
>               <container-idref>domPartnerInfoCont</container-idref>
>             </args>
>           </handler>
>         </event>
>       </radio>
>     </items>
>   </group>
>   <group column="DOMESTIC_PARTNER_INFO" name="domPartnerInfo"
>  not-null="true"
>     type="boolean"
>     unique="false"
>     optimistic-lock="true"
>     lazy="false"
>     generated="never">
>     <uses>focusObject</uses>
>     <row>1</row>
>     <region>wide</region>
>     <container-id>domPartnerInfoCont</container-id>
>     <label>Display Domestic Partner information?</label>
>     <as>checkbox</as>
>   </group>
>  </hibernate-ui>
>
>  And the XSL:
>
>  <?xml version="1.0" encoding="UTF-8"?>
>  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>   version="2.0"
>   xmlns:xs="http://www.w3.org/2001/XMLSchema";
>   xmlns:f="http://fxsl.sf.net/";
>   exclude-result-prefixes="f xs">
>
>   <xsl:import href="fxsl-xslt2/f/func-json-document.xsl"/>
>
>   <xsl:output encoding="UTF-8" indent="yes" method="xml"/>
>
>   <xsl:template match="/">
>     <hibernate-ui>
>       <xsl:apply-templates select="//*[meta[@attribute='ui']]"/>
>     </hibernate-ui>
>   </xsl:template>
>
>   <xsl:template match="*[meta[@attribute='ui']]">
>     <group>
>       <xsl:copy-of select="@*"/>
>       <xsl:apply-templates/>
>     </group>
>   </xsl:template>
>
>   <xsl:template match="meta[@attribute='ui']">
>     <xsl:copy-of select="f:json-document(.)"/>
>   </xsl:template>
>
>  </xsl:stylesheet>
>
>
>
>
>  _______________________________________________________________________
>
>  XML-DEV is a publicly archived, unmoderated list hosted by OASIS
>  to support XML implementation and development. To minimize
>  spam in the archives, you must subscribe before posting.
>
>  [Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
>  Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
>  subscribe: xml-dev-subscribe@lists.xml.org
>  List archive: http://lists.xml.org/archives/xml-dev/
>  List Guidelines: http://www.oasis-open.org/maillists/guidelines.php
>
>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS