Generate xml from xsd file
i would like to make my java application automaticaly convert a given .xsd file to an .xml one.
i know that with jdev you can generate an xml file from xsd one, and i want my application do the same thing.
i know also that i can use JAXB: first i bind the xsd file then i marshall the java class created to obtain xml. But i dont know how to do it.
is there a simple way to use the "things" behind the jdev xml generation from xsd.
Please refer
http://www.developer.com/java/web/article.php/3722211/Using-JAXB-in-JDeveloper-1013.htm
JDeveloepr 11g includes JAXB 2.0.
Similar Messages
-
Hi,
I'm not sure it's possible to do what I want, but can anyone confirm / deny this:
I have a series of XSDs that I can load into the database. I want to be able to generate XML that conforms to the XSD, by passing in a series of variables - the values that I want to substitute in the XML are not held in the database, but are all calculated in PL/SQL.
A snippet from the XML is:
<Name>
<PersonDescriptives:PersonNameTitle/>
<PersonDescriptives:PersonGivenName/>
<PersonDescriptives:PersonFamilyName/>
</Name>I want to be able to pass in variables to supply the values in the XML, and generate it from the XSD. Is this possible?
My gut feeling (and initial quick analysis) says that it's not - the option I've come up with so far is simple string manipulation and then I could validate the XML against the XSD to ensure that it's valid, but then I have the issue of what to do if it isn't valid!
Any thoughts gratefully received,
Matt
Edited by: Darryl Burke -- advertisement and links removedThanks Mark.
I've look at the examples etc already, but they all seem to only cater for selecting from a database table. Since all my values are in PL/SQL variables rather than being in tables, I guess I could select from DUAL the whole time, but the performance of having to do it that way rather than just concatenating text together doesn't seem to make it worthwhile.
Think I'll just stick with using string manipulation to create the XML.
Matt -
Hi,
Is there any tool to validate the xml file form given xsd.
Regards,
Shakirdid you not ask this before,
http://forum.java.sun.com/thread.jspa?threadID=791199
Hi,
I am new to xml.I want to validate the xml file from
a given xsd file.
Is there any tool validate xml file from a given xsd
file
Regards,
Shakir -
Programmatically generating XML from XSD
Hello, everyone:
I saw the JDev10.1.3 demo for registering an XSD and then
saw how to manually create an XML instance in JDev.
Is there a mechanism (e.g., a command line utility) for
generating an entire XML instance that is conformant to
a registered XSD? If so, it would be nice to have the
ability to create multiple conformant XML documents,
but that might be too much to ask for right now:)
Regards,
Oswald
ps: I have an XSD that imports another XSD and it seems
that I was able to register this succesfully in JDev10.1.3,
whereas it did not work when registering
the XSD in an Oracle 10G instance via 'registerSchema'.Hello:
Thanks for the update, and I tried the following:
java oracle.xml.jaxb.orajaxb -schema entity.xsd -targetPkg stuff
using the following CLASSPATH:
c:\jdev\lib\xmlparserv2.jar;c:\jdev\lib\xschema.jar;c:\jdev\xdk\lib\xml.jar;c:\j2sdk1.4.2_01\lib\tools.jar;c:\
jdev\lib
and got this error message:
XML-32011: (Error) a problem was encountered because an abstract complex type "Entity" is referenced from the element "e
ntity-elem".
and I think it's due to the line in entity.xsd:
<xsd:element name="entity-elem" type="Entity" abstract="true"/>
where Entity is defined as follows:
<xsd:complexType name="Entity" abstract="true">
<xsd:sequence>
<!-- Identification -->
<xsd:element name="uid" type="xsd:string" minOccurs="1" maxOccurs="1" nillable="true"/>
<xsd:element name="entity-type" type="xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:element ref="property-value" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
Suggestions welcome...
Regards,
Oswald -
Generating xml from xsd automated
with jdev i can generate a xml dummy document from some xsd-source. i want to do the same in a java program. is there by any chance a (the) library where i can access such a method? i know about jaxb class generation, but that is not what i need.
thanksi propably didnt make myself clear enough, sorry about that. :)
your link (jaxb):
1. generate java classes (beans)
2. write some code calling all the right setter-methods of the generated classes to fill your xml-object.
what i need:
1. write one method as explained in my earlier posting
2. compile once, use infinitly for many many different xsds without the need for further coding or recompiling.
why jaxb doesn't fulfil my requirements?
1. you have to generate classes for each new xsd you want a xmlsample for.
2. you have to write new code, calling the correct setters of the generated classes. each time you have a different xsd. -
Hi, I'm having a final project for my last year college and I really need some help here... (please)
Could anyone tell me any java library I could use to convert ESRI's SHP file (or other GIS file) to XML?
ps: an example would be very appreciate (n_n)
Thanx a ton...Please refer
http://www.developer.com/java/web/article.php/3722211/Using-JAXB-in-JDeveloper-1013.htm
JDeveloepr 11g includes JAXB 2.0. -
Generating XMLs from CSVs using DOM parser......
Hi,
I am trying to generate XMLs from CSV files using DOM parser. XMLs are getting generated but the problem is that i am using Encoding "ISO-8859-1" but XMLs are getting generated in UTF-8 encoding.
Please refer to the code below and advice. (where are the code tags gone ????? )
Source domSource = new DOMSource(document);
ByteArrayOutputStream xmlStream = new ByteArrayOutputStream();
Result result = new StreamResult(xmlStream);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(domSource, result);
xmlStream.close();
generatedXml = new String(xmlStream.toByteArray(), "*ISO-8859-1*");Use transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1") to specify the character set.
-
Creating a XML file from XSD file
Is there a piece of Java code that will convert a file to XML using a XSD without the use of generated Java classes?
Thanks alot,
AmyI tried the link in asp.net but When I double click the exe it just pops off and goes.....How to use C# application......I am using Visual web developer 2005......please help in creating XML from XSD file
-
Generating XML from SQL queries and saving to an xml file?
Hi there,
I was wondering if somebody could help with regards to the following:
Generating XML from SQL queries and saving to a xml file?
We want to have a procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
is accessed by our software on the client machine).
Using this order number we do a couple of SQL queries.
My first question: What would be our best option to convert the result of the
queries to xml?
Second Question: Once the XML has been generated, how do we save that XML to a file?
(The XML file is going to be saved on the file system of the server that
the database is running on.)
Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
the client hard drive.
Any information would be greatly appreciated.
Thanking you,
FrancoisIf you are using 9iR2 you do not need to do any of this..
You can create an XML as an XMLType using the new SQL/XML operators. You can insert this XML into the XML DB repository using DBMS_XDB.createResource. You can then access the document from the resource. You can also return the XMLType containing the XML directly from the PL/SQL Procedure. -
Generating XML from SQL queries and saving to a xml file?
Hi there,
I was wondering if somebody could help with regards to the following:
Generating XML from SQL queries and saving to a xml file?
We want to have a stored procedure(PL/SQL) that accepts an order number as an input parameter(the procedure
is accessed by our software on the client machine).
Using this order number we do a couple of SQL queries.
My first question: What would be our best option to convert the result of the
queries to xml?
Second Question: Once the XML has been generated, how do we save that XML to a file?
(The XML file is going to be saved on the file system of the server that
the database is running on.)
Now our procedure will also have a output parameter which returns the filename to us. eg. Order1001.xml
Our software on the client machine will then ftp this XML file(based on the output parameter[filename]) to
the client hard drive.
Any information would be greatly appreciated.
Thanking you,
FrancoisHi
Here is an example of some code that i am using on Oracle 817.
The create_file procedure is the one that creates the file.
The orher procedures are utility procedures that can be used with any XML file.
PROCEDURE create_file_with_root(po_xmldoc OUT xmldom.DOMDocument,
pi_root_tag IN VARCHAR2,
po_root_element OUT xmldom.domelement,
po_root_node OUT xmldom.domnode,
pi_doctype_url IN VARCHAR2) IS
xmldoc xmldom.DOMDocument;
root xmldom.domnode;
root_node xmldom.domnode;
root_element xmldom.domelement;
record_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
xmldom.setDoctype(xmldoc, pi_root_tag, pi_doctype_url,'');
-- Create the root --
root := xmldom.makeNode(xmldoc);
-- Create the root element in the file --
create_element_and_append(xmldoc, pi_root_tag, root, root_element, root_node);
po_xmldoc := xmldoc;
po_root_node := root_node;
po_root_element := root_element;
END create_file_with_root;
PROCEDURE create_element_and_append(pi_xmldoc IN OUT xmldom.DOMDocument,
pi_element_name IN VARCHAR2,
pi_parent_node IN xmldom.domnode,
po_new_element OUT xmldom.domelement,
po_new_node OUT xmldom.domnode) IS
element xmldom.domelement;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
BEGIN
element := xmldom.createElement(pi_xmldoc, pi_element_name);
child_node := xmldom.makeNode(element);
-- Append the new node to the parent --
newelenode := xmldom.appendchild(pi_parent_node, child_node);
po_new_node := child_node;
po_new_element := element;
END create_element_and_append;
FUNCTION create_text_element(pio_xmldoc IN OUT xmldom.DOMDocument, pi_element_name IN VARCHAR2,
pi_element_data IN VARCHAR2, pi_parent_node IN xmldom.domnode) RETURN xmldom.domnode IS
parent_node xmldom.domnode;
child_node xmldom.domnode;
child_element xmldom.domelement;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
create_element_and_append(pio_xmldoc, pi_element_name, pi_parent_node, child_element, child_node);
parent_node := child_node;
-- Create a text node --
textele := xmldom.createTextNode(pio_xmldoc, pi_element_data);
child_node := xmldom.makeNode(textele);
-- Link the text node to the new node --
compnode := xmldom.appendChild(parent_node, child_node);
RETURN newelenode;
END create_text_element;
PROCEDURE create_file IS
xmldoc xmldom.DOMDocument;
root_node xmldom.domnode;
xml_doctype xmldom.DOMDocumentType;
root_element xmldom.domelement;
record_element xmldom.domelement;
record_node xmldom.domnode;
parent_node xmldom.domnode;
child_node xmldom.domnode;
newelenode xmldom.DOMNode;
textele xmldom.DOMText;
compnode xmldom.DOMNode;
BEGIN
xmldoc := xmldom.newDOMDocument;
xmldom.setVersion(xmldoc, '1.0');
create_file_with_root(xmldoc, 'root', root_element, root_node, 'test.dtd');
xmldom.setAttribute(root_element, 'interface_type', 'EXCHANGE_RATES');
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mr', record_node);
parent_node := create_text_element(xmldoc, 'name', 'Joe', record_node);
parent_node := create_text_element(xmldoc,'surname', 'Blogs', record_node);
-- Create the record element in the file --
create_element_and_append(xmldoc, 'record', root_node, record_element, record_node);
parent_node := create_text_element(xmldoc, 'title', 'Mrs', record_node);
parent_node := create_text_element(xmldoc, 'name', 'A', record_node);
parent_node := create_text_element(xmldoc, 'surname', 'B', record_node);
-- write the newly created dom document into the buffer assuming it is less than 32K
xmldom.writeTofile(xmldoc, 'c:\laiki\willow_data\test.xml');
EXCEPTION
WHEN xmldom.INDEX_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Index Size error');
WHEN xmldom.DOMSTRING_SIZE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'String Size error');
WHEN xmldom.HIERARCHY_REQUEST_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Hierarchy request error');
WHEN xmldom.WRONG_DOCUMENT_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Wrong doc error');
WHEN xmldom.INVALID_CHARACTER_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Invalid Char error');
WHEN xmldom.NO_DATA_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Nod data allowed error');
WHEN xmldom.NO_MODIFICATION_ALLOWED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'No mod allowed error');
WHEN xmldom.NOT_FOUND_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not found error');
WHEN xmldom.NOT_SUPPORTED_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'Not supported error');
WHEN xmldom.INUSE_ATTRIBUTE_ERR THEN
RAISE_APPLICATION_ERROR(-20120, 'In use attr error');
WHEN OTHERS THEN
dbms_output.put_line('exception occured' || SQLCODE || SUBSTR(SQLERRM, 1, 100));
END create_file; -
XML and XSD file to an internal table
I had read a lot of thread but i don't understand how to deal with xml/xsd in R3.
I need someone that have a definite example for this escenary please.
With OPEN DATASET took from the server XML and XSD file, and put it in two internal tables type string.
What functions or method have to use, and how to use them, to charge the XML file in an internal table?
This is an example of XML and XDS:
XML
AND CONTINUE
Best Regards,I just tried to interpret your question, it was not obvious what you wanted.
I guess what you mean is that you have defined (statically) a deep structure, and you want to decode the XML into it. That is called a transformation (transaction STRANS, statement CALL TRANSFORMATION). You have the choice between 2 transformation languages: XSLT and ST. Of course, it depends what release you are running.
I advise you to play first with the ID transformation, to convert an ABAP deep structured data object into XML, so that you see what XML is generated, this one is called asXML. If you create your own transformation, when you call it, it will first convert automatically the data object to asXML, and the transformation has to do the rest of the job.
You can do the opposite, i.e. converting from XML to a data object, according to the same principle (intermediate asXML).
Well, there are lots of things to say, I recommend you to read articles and documentation on XSLT and ST (search on SDN).
About XSD, it won't help (and I did never see any possibility to use it) to decode the XML, as you must anyway define the target data object statically (and there's no tool to generate the ABAP code of the data object definition from the XSD).
Note that you may also use iXML libraries to parse the XML.
Please tell us more.
BR
Sandra -
How to create JSF application from xsd files?
Hi,
We have many xsd files describing xml's which we are supposed to send to web services. Application which we are creating should allow user to fill xml documents with data and then we should send those xml files to some web service. We want to automatize as much as possible the process of application creation to avoid possible errors and to minimize our efforts (there are plenty of quite complex xsd files).
Our first approach was: we used Oracle JSXB to generate java classes basing on xsd files (using JDeveloper 10.1.3.2.0.4066). Then we tried to generate DataControls, but this action fails with following error:
Window title: Error in init bean
Message: Could not complete initbean because it would result in an invalid document
Details: oracle.bali.xml.model.XmlInvalidOnCommitException: SEVERE: Wartość atrybutu Name nie jest typu ID (Value of Name attribute is not of ID type)
Wartość musi być następującego typu: (Value must be of following type)
Nazwa typu: ID (Type name)
Typ pierwotny: string (Primitive type)
Z następującymi więzami: (With following constraints)
zgodne z wzorcem: [\i-[:]][\c-[:]]* (Compliant with template)
[ node = Name ]
<JavaBean version="10.1.3.40.66" id="XSLStylesheet" BeanClass="oracle.xml.xslt.XSLStylesheet" Package="oracle.xml.xslt" isJavaBased="true">
<Attribute Name="classMethodParams" IsUpdateable="0" Type="java.util.Hashtable" />
We tried Sun implementation fo JAXB - it generated different java classes (with annotation mechanism). Creation of DataControls using those classes was successful. Then we created simple JSF page and tried to put those DataControls on it in order to let the user fill it with data. The thing is that those controls are read only as there is no row created in those DC. We can't create any row in those DC as there are only 'commit' and 'rollback' operations. When we try to call 'CreateInsert' operation on child elements of those DC we get error in JDeveloper log window:
2007-05-29 10:08:46 oracle.adf.controller.faces.lifecycle.FacesPageLifecycle addMessage
WARNING: JBO-29000: DataControl:createRowData
2007-05-29 10:08:46 oracle.adf.controller.faces.lifecycle.FacesPageLifecycle addMessage
WARNING: DataControl:createRowData
new row is not created and controls are still read-only.
The question is:
1. is there another, more efficient way to create JSF application from xsd files?
2. if this is the best way to do it, what do we do wrong?
LeszekTo anyone who might find it useful: our solution to mentioned problem.
Few tips how to solve described problem:
1. Do not use JAXB (we checked Oracle and Sun)
2. Use castor http://www.castor.org/
a) for each xsd generate java files in separated package
b) use java 1.5 to let castor generate lists
c) use mapping of xml namespaces to java packages to have only 1 implementation of each xsd
3. Create facades - java files for you root-level java objects
4. Right click those facades and choose 'Create DataControl' in jdev
5. Now you may drag and drop you DataControls and use them in your JSF (or UIX) application
I hope it will help someone :)
Leszek -
I'm a total newbie in XML DB and need advice on generating XML from database.
The situation is the following: there is a legacy web application which uses an XML document as a configuration file. This document conforms to some well-defined schema. For instance:
<config>
<title value="TITLE" />
<subtitle value="SUBTITLE" />
<style url="default.css" />
<widgets>
<widget id="1" opened="true" />
<widget id="2" opened="false" />
</widgets>
</config>
It contains portions of static data which are common for all users as well as dynamic personal data.
Dynamic data comes from two sources:
1) security considerations (for instance, not all widgets are available for some users) - thus the "master" configuration content must be filtered, but not otherwise modified;
2) user preferences (for instance, user can set widget2 to be opened by default) - thus values of some attributes must be different for each user. When the user saves her preferences, the entire document with new values is posted back to server.
We want to try to store user preferences, apply security and generate personalized configuration documents using XML DB.
So we need advice on storage models and generation procedures - which should be more efficient and easy to support or extend.
Please note, that there is no requirement to actually store data as XML.
Thanks in advance!
P.S.: Sorry for the incomplete initial post.
Edited by: WxD on 27.09.2010 11:45Hi,
See this link for more details
http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10790/xdb13gen.htm -
Facing problem in xml schema xsd file registration
Hi,
i am facing problem in xml schema xsd file registration when
the number of column is more. It is showing persing error.
if i am deleting few column from xsd file . It is working otherwise
showing error. Is there any solution for that please suggest me.
The Error is
ORA-31011:XML parsing failed
ORA_19202: Error occurred in XML processing
LPX-00230 : (message vary time to time-like invalid tag ending etc.)
Regards
Manoranjan
and thanks in advanceWhere is you XML coming from. Are you sure it's valid. If you are hard coding it as a SQL String constant are you hitting the 4k / 32K limit on the size of SQL / PL/SQL constant. Have you tried loading the content from a bfile..
-
Hide name space of generated xml from xml bean
Hi,
how can i hide the namespace of the generated xml from xml bean, cause im having problems with jaxb parses.The targetNamespace is for webservice and not for the user defined classes.
Sorry for the confusion
Ajay
"Ajay" <[email protected]> wrote in message
news:[email protected]..
There is a targetNamespace attribute in the autotyp ant task. But there
was a bug in 8.1. Contact the support for a patch.
The following mail explains that
This looks like a bug. There is an undocument, not officially
supported workaround: add the following java doc
to yours source code -
* @wlws:webservice targetNamespace="http://foo.bar"
public class MyService {
Details here:
http://www.manojc.com/tutorial/sample3/source2wsdd.html
Regards,
-manoj
http://manojc.com
"Mark Fine" <[email protected]> wrote in message
news:[email protected]..
The attribute targetNamespace (of the autotype task) doesn't seem to putany
information into the types file and later my deployment descriptor (viathe
source2wsdd task) contains an invalid targetNamespace attribute with a
http://tempuri.org:
eg.
<web-services>
<web-service name="IndexService"
targetNamespace="http://tempuri.org/"
uri="/IndexWebService">
I don't think this causes any problems but there should be a way tospecify
the namespace.
Has anyone else seen this is WLS8.1?
"Siva" <[email protected]> wrote in message
news:[email protected]..
By default the autotype or the servicegen ant task seem to be creating anamespace
from the java package name (like java:com.ventaso.external.common) for
xml
mapping
of user defined java classes. Is there a way to change this to name
space
I want
? Specifying the targetnamespace doesn't seem to help.
Thanks,
Siva
Maybe you are looking for
-
I just bought a new 4s and I can't activate using cellular connection, what is wrong?
I just bought a new 4s and I can't activate it using cellular connection and Wi-Fi and also I can't seem to get the iTunes connection option from my phone as well. What can I do?
-
I have tried to update this phone so long it keeps saying it is stuck in recovery mode, and when does update it go on to say it's firmware is wrong and can't update. I don't what else to do except to unlock this phone now please I need help to solv
-
I have exported a project, using the file/export option. The project is exported to a external disk connected on the local network. When importing this project, no files are seen. Only two sub-directories (no related name, only numbers and some lette
-
PARTSTAT=ACCEPTED:urn:uuid: or PARTSTAT=ACCEPTED:mailto:
I'm testing iCal Server so I'm currently the only one in our organization on iCal Server. *The problem:* When I reply to an event invitation, an email with an .ics with my reply is sent with my local Mail.app. But it is not accepted by the inviters l
-
Premiere 4 elements - new project creation problem
Let me say first that this product does all I want. I have discovered a problem that has only just popped up. I have for a long time directed it to D:\videos. And previously when I created a new project within this directory the software created the