[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Simple API for accessing data in an XML file in Java ? without ha vingto

  • From: Arthur Senator <asenator@s...>
  • To: "'xml-dev@l...'" <xml-dev@l...>
  • Date: Wed, 18 Apr 2001 17:09:14 -0400

java xml file
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). 
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>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.