Archive for the 'XML' Category

How to solve XML reffers to not existing parent error of dhtmlxTree

Written by coregps on Thursday, March 13th, 2008 in Java, AJAX, XML.

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

When I use dhtmlxTree dynamical loading with jsp, I always get the following exception:

Error type: DataStructure
Description: XML reffers to not existing parent

The code of the jsp page is as following:

<html>
<head>
</head>
<body>
    <link rel="STYLESHEET" type="text/css" href="css/dhtmlxtree.css">
    <script  src="js/dhtmlxcommon.js"></script>
    <script  src="js/dhtmlxtree.js"></script>
    <div id="treeboxbox_tree" style="width:100%; height:218;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"></div>
    <script type="text/javascript">
		tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
		tree.attachEvent("onClick",onNodeSelect);
		tree.setImagePath("images/tree/");
		tree.setXMLAutoLoading("AdminFolderServlet?action=folder_treeview");
		tree.loadXML("AdminFolderServlet?action=folder_treeview&id=1");
		function onNodeSelect(nodeId){
		    document.getElementById("parent_folder_id").value = nodeId;
		}
    </script>
</body>
</html>

And the following is the code snippet used to generate XML file of the tree:

String id = request.getParameter("id");
if (id == null) id = "1";
Vector folders = Folder.getFolders(Integer.parseInt(id));
StringBuffer buff = new StringBuffer("< ?xml version=\"1.0\"?>“);
buff.append(”
“);
for (int i = 0; i < folders.size(); i++) {
	Folder f = (Folder)folders.get(i);
	buff.append("“);
}
buff.append(”“);
response.setContentType(”text/xml”);
response.setHeader(”Cache-Control”,”no-cache”); //HTTP 1.1
response.setHeader(”Pragma”,”no-cache”); //HTTP 1.0
response.setDateHeader(”Expires”, 0); //prevents caching at the proxy server
response.getWriter().write(buff.toString());

The generated XML is well formed.

<?xml version="1.0"?>
<tree id='1'>
	<item child='1' id='2' text='Games' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='1' id='3' text='Music' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='0' id='4' text='Books' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='1' id='5' text='Movies' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='1' id='6' text='Photos' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
	<item child='0' id='14' text='Articles' im0='folderClosed.gif' im1='folderOpen.gif' im2='folderClosed.gif'></item>
</tree>

I finally found the solution. The id attribute of the tree element must point to the parent id, which data will be linked, by default super-root ID = 0, but it can be changed while tree initialization ( 4th parameter of constructor ), In case of dynamic loading the tree id must be equal to the parent ID for which data requested.

In my database, the root id of the top level folder is 1, however, I use 0 in the tree initialization method.

tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);

So, I got the exception. After changing the fourth parameter to 1, it works well.

tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",1);

Hope this can help someone else in the future :)

propecia pricebuy propeciaorder ventolinbuy ventolincheap xenicalxenical onlneorder revatiorevatiofemale viagra onlinefemale viagracompare viagra cialisorder viagra cialischeap vpxlvpxl onlineorder levitra professionallevitra professional onlinebuy levitra prescriptionlevitralevitra onlineorder cialis jellycialis jellyorder cialis soft tabsbuy cialis soft tabsorder cialis super activecheap cialis super activeorder generic cialischeap generic cialiscialis professionalcialis professional onlinepurchase cialiscialis pricecialischeap brand viagrabrand viagra onlineviagra jelly onlineviagra jelly priceorder viagra soft tabsbuy viagra soft tabsviagra super active onlineviagra super activeorder generic viagracheap generic viagraviagra professional onlineviagra professionalpurchase viagraviagracheap viagraorder vpxlbuy vpxltake viagra cialis togetherorder viagra cialis onlinelevitra professional pricecheap levitra professionallevitrabuy levitracialis jelly pricecheap cialis jellycialis soft tabscialis soft tabs onlineorder cialis super activecialis super activeorder generic cialischeap generic cialischeap cialis professionalcialis professional priceorder cialischeap cialischeap brand viagrabrand viagra onlineorder viagra jellyviagra jelly pricecheap viagra tabsviagra soft tabs onlineviagra super active onlinecheapviagra super activegeneric viagrageneric viagra onlineorder viagra professionalcheap viagra professionalviagra pricebuy viagrabuy cialis ukwhat is cialiscialis sale ukpurchase generic cialisbuy cialis money orderbuy cialis low costbuy cialis in ukbuy cialis huge discounts onlinebuy cialis from usa onlinebuy cialis fedex shippingorder cialis and viagrabuy cialis no prescriptionbuy cialis amexbuy cialis by mailbest cialis pricesorder viagra international shipscheapest place to buy viagra onlineviagra purchasebuy taladafil viagraviagra mail order ukviagra low pricecheap site buy viagrabuy generic viagra canadaviagra drugs order brand pillviagra best quality lowest priceshow to buy viagra onlinebuy viagra online securelybuy viagra online pharmacybuy viagra online get prescriptionbest way to take levitrabest price viagra or levitrabest price viagra official drug storeorder viagra with master cardorder viagra upsbuy viagra in englandbuy viagra consumers discount

A Java based XML browser : X-Smiles

Written by coregps on Friday, July 29th, 2005 in Java, XML.

X-Smiles is  a Java based XML browser. It is intended for both desktop use and embedded network devices and to support multimedia services.


The main advantage of the X-Smiles browser is that it supports several XML related specifications and is still suitable for embedded devices supporting the Java environment.


The main objective of X-Smiles project is to deliver a pure Java XML browser, capable of displaying documents written in various XML languages. The X-Smiles browser should support at least:



  • XML+CSS
  • XHTML
  • XSL Transformations (XSLT)
  • Synchronised Multimedia Integration Language (SMIL)
  • XForms
  • XHTML
  • X3D
  • Scalable Vector Graphics (SVG)
  • XSL Formatting Objects (XSL FO)

I was so excited when I found this baby. Don’t wait any more! I’m sure that you will be excited by this soooooooooooooooooo coooooooooooooooool browser too!


To take a look at screen shots of X-Smiles at http://www.xsmiles.org/screenshots.html 


Download X-Smiles at http://www.xsmiles.org/download.html


For more information of X-Smiles, visit http://www.xsmiles.org/index.html.

XForms Institute

Written by coregps on Friday, July 29th, 2005 in XML.

XForms Institute privides interactive, cross-platform tutorial on W3C XForms. Interactive lessons are provided through a tiny Flash plugin that implements a large percentage of XForms, XHTML, and CSS level 3. Readers that do not have Flash available will still be able to benefit from the tutorials.

For more information about XForms Institute, visit http://xformsinstitute.com/.

Make the formsPlayer plug-in works in IE6

Written by coregps on Friday, July 29th, 2005 in XML.

formsPlayer is a set of libraries that were created to make it possible to build XForms processors, editors and debuggers. To make it works in IE6, you can follow the steps below.

Download

1. Download the files mscomctl.ocx and mscomct2.ocx which will be used by formsPlayer to display some XForms controls correctly.

2. Download the Microsoft XML Parser 4.0 from here.

3. Download formsPlayer from here and the latest patch here.

Install

1. Place the two .ocx files into your Windows\System32 folder, and run the following command one by one:

regsvr32 mscomctl.ocx
regsvr32 mscomct2.ocx

2. Install the Microsoft XML Parser 4.0.
3. Install formsPlayer.
4. Install the latest patch.

Explore

The formsPlayer plug-in runs inside version 6 of Microsoft’s Internet Explorer. The XForms tags are embedded in an ordinary HTML document, but by using various namespace settings we can ask IE to give control to formsPlayer when it sees XForms tags:

<object id=”FormsPlayer” classid=”CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58″ width=”0″ height=”0″>
  <b>FormsPlayer has failed to load! Please check your installation.</b>
</object>

<?import namespace=”xforms” implementation=”#FormsPlayer”?>

It is important that the namespace prefix declared in the <?import?> processing instruction matches that used when declaring the XForms namespace on the <html> element:

<html xmlns=”http://www.w3.org/1999/xhtml” xmlns:xforms=”http://www.w3.org/2002/xforms“>
  …
<?import namespace=”xforms” implementation=”#FormsPlayer”?>

Also, the id attribute of <object> can be anything you like, but make sure that the implementation attribute on <?import?> refers to it correctly:

<object id=”FormsPlayer” classid=”CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58″>
  …
<?import namespace=”xforms” implementation=”#FormsPlayer“?>

Example (hello.html)

<?xml version=”1.0″ encoding=”UTF-8″?>
<html xmlns=”
http://www.w3.org/1999/xhtml” xmlns:xforms=”http://www.w3.org/2002/xforms“>
<object id=”FormsPlayer” classid=”CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58″ width=”0″ height=”0″>
  <b>FormsPlayer has failed to load! Please check your installation.</b>
</object>
<?import namespace=”xforms” implementation=”#FormsPlayer”?>
<head>
<xforms:model>
  <xforms:instance>
  <person>
    <fname/>
    <lname/>
  </person>
  </xforms:instance>
  <xforms:submission id=”form1″ method=”get” action=”hello.html” />
</xforms:model>
</head>

<body>
<xforms:input ref=”fname”>
  <xforms:label>First Name</xforms:label>
</xforms:input>
<br />
<xforms:input ref=”lname”>
  <xforms:label>Last Name</xforms:label>
</xforms:input>
<br />
<br />
<xforms:submit submission=”form1″>
  <xforms:label>Submit</xforms:label>
</xforms:submit>
</body>
</html>

Make XForms Works In IE

Written by coregps on Friday, July 29th, 2005 in XML.

W3C XForms is an update to HTML forms and provides an extensible means to include richer, more dynamic forms in HTML documents. However, it seemed that the browser could not parse it correcly. When I save the code below as helloworld.xforms and open it in IE, it does not appear as expected. So, I surf the web for the solution. Finally, I find the IBM XML Forms Package. After the following two steps, XForms says hello to me!


1. Install IBM XML Forms Package. (http://alphaworks.ibm.com/tech/xmlforms)


2. Download the latest MS parser and update it (http://www.microsoft.com/downloads/details.aspx?FamilyID=c0f86022-2d4c-4162-8fb8-66bfc12f32b0&DisplayLang=en).


Here is the code (helloworld.xforms):



<html xmlns:xforms=”http://www.w3.org/2002/xforms/cr“>
<head>
<xforms:model>
  <xforms:instance>
  <person>
    <fname/>
    <lname/>
  </person>
  </xforms:instance>
  <xforms:submission id=”form1″ method=”get” action=”submit.jsp”/>
</xforms:model>
</head>


<body>
<xforms:input ref=”fname”>
  <xforms:label>First Name</xforms:label>
</xforms:input>
<br />
<xforms:input ref=”lname”>
  <xforms:label>Last Name</xforms:label>
</xforms:input>
<br />
<br />
<xforms:submit submission=”form1″>
  <xforms:label>Submit</xforms:label>
</xforms:submit>


</body>
</html>


You can visit http://alphaworks.ibm.com/tech/xmlforms for detail information about IBM XML Forms Package.



Site Navigation