Reading and writing XML instances from DTDs

Source: Internet
Author: User
Tags empty final return
XML package Franzy;

Import org.w3c.dom.Element;
Import oracle.xml.parser.v2.XMLElement;
Import oracle.xml.parser.v2.XMLDocument;
Import Com.biztunnel.util.tools.ToolKit;

public class Agency
{
Private String Agencyid;
Private String Agencyother;
Private String A_dtype;
private element element;

public static final String Agencycode_other = ' other ';
public static final String Agencycode_commerceone = "CommerceOne";
public static final String Agencycode_iso = "ISO";
public static final String Agencycode_ean = "EAN";
public static final String agencycode_assignedbysupplier = "Assignedbysupplier";
public static final String Agencycode_assignedbybuyer = "Assignedbybuyer";
public static final String Agencycode_ansi = "ANSI";
public static final String Agencycode_gbaba = "Gbaba";
private static final String agency_attribute_a_dtype= "%agency-dtypes;";

/**
* Creates a Agency element according to the outer element
*/
private void Init ()
{
This.element=new XmlElement ("Agency");
Agencyid = null;
Agencyother = null;
A_dtype = this. Agency_attribute_a_dtype;
}

Public Agency (Element newelement)
{
Init ();

Element newelement = (Element) newelement1.getlastchild ();
if (!newelement.getnodename (). Equals ("Agency"))
if (!newelement1.getlastchild (). Getnodename (). Equals ("Agency"))
{
System.out.println ("Not it!!!");

}
Get attribute
This.setagencyid (Newelement.getattribute ("Agencyid"));
This.setagencyother (Newelement.getattribute ("Agencyother"));
This.agencyid = Newelement.getattribute ("A-dtype");
}

/**
* Create an empty Agency element according to the BUGINFO.DTD
*/
Public Agency ()
{
Initialize the empty node
This.init ();
}

/**
* Convert this element to the format
*/
Public Element getelement ()
{
if (This.getagencyid ()!=null)
{
This.element.setAttribute ("Agencyid", This.getagencyid ());
}
if (This.getagencyother ()!=null)
{
This.element.setAttribute ("Agencyother", This.agencyother);
}
if (This.geta_dtype ()!=null)
{
This.element.setAttribute ("A-dtype", This.a_dtype);
}
return this.element;
}


public void Setagencyid (String Newagencyid)
{
Agencyid = Newagencyid;
}

Public String Getagencyid ()
{
return Agencyid;
}

public void Setagencyother (String newagencyother)
{
Agencyother = Newagencyother;
}

Public String Getagencyother ()
{
return agencyother;
}

Public String Geta_dtype ()
{
return a_dtype;
}

public void Setfixeda_dtype (Boolean isSet)
{
if (IsSet)
{
A_dtype = this. Agency_attribute_a_dtype;
}
Else
{
A_dtype = null;
}
}

public static void Main (string[] args)
{
Try
{
Test 1
Agency element= new Agency ();
Element.setfixeda_dtype (TRUE);
Element.setagencyid (Agency.agencycode_assignedbybuyer);
Element.setagencyother ("other");
XmlDocument doc = new XmlDocument ();
Doc.appendchild (Element.getelement ());
System.out.println (Toolkit.getxmlstring (DOC));

Test 2
Agency element1= New Agency (Element.getelement ());
System.out.println (Element1.geta_dtype ());
}catch (Exception e)
{
E.printstacktrace ();
}

}
}

Come to me with a problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.