[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Simple API for accessing data in an XML file in Java ? without having to write all the parsing code myself
- From: Thomas Nichols <thomas.nichols@iname.com>
- To: Arthur Senator <asenator@synapsemail.com>, xml-dev@lists.xml.org
- Date: Thu, 19 Apr 2001 00:10:28 +0100
At 17:09 18/04/01 -0400, Arthur Senator wrote:
>I would like to use something simple 'like' the Microsoft ADO record set
>object (a cursor that enables to retrieve and update very simply from/to an
>XML file).
Have you looked at JDOM? http://www.jdom.org - the cleanest Java API I've
found so far, though less database-oriented than RAX.
A good selection of parsers is at
http://martin.bernauer.at/xmlentity/software-developer.html
- Thomas.
>I am not a Microsoft developer, yet was shown that and was quite impressed
>by the simplicity of that API and wondering if there is any equivalent in
>Java.
>
>This is a dramatic simplification of things especially in an application
>that constantly need to read and write to such a file. (Possibly for
>hundreds of attributes)
>Since I don't need to build relations between nodes or to express any
>model/relations in my XML file and don't want to traverse enumerations (DOM)
>or use events (SAX) to get and set a s-i-n-g-l-e value (big overhead .. the
>parsing ) . I don't need in this particular case to write all the parsing
>(overkill)
>
>The Microsoft implementation allows to filter by attribute or combination of
>attributes (equivalent of a SQL where clause).
>
>
>If there is no API I may have to resort to using a cached properties file or
>store the whole thing in a database and cache it.
>
>Thanks
>Ari
>
>Here is an example of the ASP and XML file that stores the data
>
> set oRSXML = server.CreateObject("adodb.recordset")
> oRSXML.CursorLocation = adUseClient
> oRSXML.CacheSize = 100
> ....
> ....
>
>function GetXMLElement(oRSXML, sElementName)
> 'this function searches oRSXML for the first occurence of the
>sElementName parameter
> 'if the element is found then the text value associated with the
>element is returned
> 'on error resume next
> dim sElement
> oRSXML.movefirst
> oRSXML.find("ElementName = '" & sElementName & "'")
> if err <> 0 or oRSXML.bof or oRSXML.eof then
> GetXMLElement = ""
> else
> GetXMLElement = oRSXML("value")
> end if
>end function
>
>
>
><xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
> xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
> xmlns:rs='urn:schemas-microsoft-com:rowset'
> xmlns:z='#RowsetSchema'>
><s:Schema id='RowsetSchema'>
> <s:ElementType name='row' content='eltOnly' rs:updatable='true'>
> <s:AttributeType name='ElementName' rs:number='1'
>rs:write='true'>
> <s:datatype dt:type='string' rs:dbtype='str'
>dt:maxLength='50' rs:precision='0' rs:maybenull='false'/>
> </s:AttributeType>
> <s:AttributeType name='Desc' rs:number='2' rs:write='true'>
> <s:datatype dt:type='string' rs:dbtype='str'
>dt:maxLength='50' rs:precision='0' rs:maybenull='false'/>
> </s:AttributeType>
> <s:AttributeType name='PageName' rs:number='3'
>rs:write='true'>
> <s:datatype dt:type='string' rs:dbtype='str'
>dt:maxLength='50' rs:precision='0' rs:maybenull='false'/>
> </s:AttributeType>
> <s:AttributeType name='SectionName' rs:number='4'
>rs:write='true'>
> <s:datatype dt:type='string' rs:dbtype='str'
>dt:maxLength='50' rs:precision='0' rs:maybenull='false'/>
> </s:AttributeType>
> <s:AttributeType name='Value' rs:number='5' rs:write='true'>
> <s:datatype dt:type='string' rs:dbtype='str'
>dt:maxLength='1024' rs:precision='0' rs:maybenull='false'/>
> </s:AttributeType>
> <s:AttributeType name='Title' rs:number='6' rs:write='true'>
> <s:datatype dt:type='string' rs:dbtype='str'
>dt:maxLength='50' rs:precision='0' rs:maybenull='false'/>
> </s:AttributeType>
> <s:extends type='rs:rowbase'/>
> </s:ElementType>
></s:Schema>
>
><rs:data>
> <z:row ElementName='NumberMonthsFree' Desc='Number Months'
>PageName='Admin2' SectionName='NumberMonths'
> Value='2' Title=''/>
> <z:row ElementName='TopImageFile' Desc='Top Navbar Image '
>PageName='Frame' SectionName='Image' Value='GMP_22222222_003_01.gif'
> Title=''/>
> <z:row ElementName='BottomImageFile' Desc='Bottom Navbar Image '
>PageName='Frame' SectionName='Image' Value='GMP_22222222_000_06.gif'
> Title=''/>
></rs:data>
></xml>
>
>
>------------------------------------------------------------------
>The xml-dev list is sponsored by XML.org, an initiative of OASIS
><http://www.oasis-open.org>
>
>The list archives are at http://lists.xml.org/archives/xml-dev/
>
>To unsubscribe from this elist send a message with the single word
>"unsubscribe" in the body to: xml-dev-request@lists.xml.org