How to add xml schema within xml using jaxb

I want to add schema in xml file using jaxb.I can generate java sources from schema and generate xml file from this sources but now I want to add this schema with in this xml.
My schema is look like, It is only a demo schema originally it is also big.

Please give some code snips to configure the jaxb by which I can add this schema in xml file.

I want to jaxb because my original xml file size is very big and it contains so many tags.I also go through this site docs.oracle.com/javase/tutorial/jaxb/intro/custom.html but I did not get any idea.My xml file should be look like.

You have already asked this question several times. Since you haven't received any answers yet, chances are that nobody reading these forums knows the answer.

Or here's another possibility: I strongly suspect that the answer is "No, you can't do that" but I'm not interested in doing the research to confirm that answer. Reading the documentation for a product in order to confirm that it can not do something is very difficult. I expect other people may feel the same way.

moin roy
Greenhorn

Joined: Mar 28, 2012
Posts: 15

posted Apr 05, 2012 12:10:19

0

@Paul Clapham I receive your answer on previous thread but you give me your reply by using dom4j which is dom parser but it can not be used in my present scenario because I have a large xml data,and which I asked in previous thread you did not give any reply please give me some idea.
Your example code totally make the xml file using dom4j and use getter setter method from jaxb.

I have an idea that if I generate large xml file with data using jaxb after making this abc.xml file now dom parser or other parser open this file and write the schema under <transaction> tag before <id> tag,but I am till now unable to put someting under <transaction> before <id>

Thanks for your previous reply on old thread it was a nice post,Please give me some positive reply I am waiting for that.

@William P O'Sullivan yeap you are right did you see my post in this thread can you say that I am right or wrong?what I try to do is it a correct approach?please reply I am new in java please give some idea which can en-light me.

moin roy
Greenhorn

Joined: Mar 28, 2012
Posts: 15

posted Apr 05, 2012 23:50:37

0

@Paul Clapham oh I am really sorry I am new in forum so I made a mess,please don't mind.Thanks for your reply.

Totally agree with Amit here. Why do you want to add the schema to the XML that was generated from it?

moin roy
Greenhorn

Joined: Mar 28, 2012
Posts: 15

posted Apr 09, 2012 12:26:51

0

@James Boswell and amit punekar It is necessary to describe the whole thing ok lets start.Actually the application is make using C# on .NET 3.5,here after running the application it generate a transaction file(xml data+schema) looks like my demo xml file.Now this xml file automatically deleted from local machine and push to central database and store the xml data and if I corrupt any portion of this file it will not update the database for example if I delete the schema part of the generated file then it will unable to update the database.

Now question is why I want to make this file,basically I am a tester so I test this file properly update the database or not on different value or different configuration.It is very Time consuming that to ran the original application and generate the file.So I want to make this application by which I can generate this type of file in 100 times holding the same configuration or different.I want to make this using java because I know little bit of java.

Is it possible to using web service?because my original application is also use web service.

If web service is the main reason then please tell me how to use web service and how to access it if you give me some code snips then it will be helpful.

That was my impression too. What on earth is the point of including the schema inside the document it's supposed to validate? Wouldn't that make the document invalid? But then I googled for "inline schema" and got a lot of links which suggested to me that a lot of people want to do this, even though I think it's a totally weird thing to do. But then I don't work in an environment where we have to deal with schemas, so my opinion doesn't count for much.

arjun ray wrote:Now question is why I want to make this file,basically I am a tester so I test this file properly update the database or not on different value or different configuration.It is very Time consuming that to ran the original application and generate the file.So I want to make this application by which I can generate this type of file in 100 times holding the same configuration or different.I want to make this using java because I know little bit of java.

Looks like the idea that you know a little bit of Java, therefore you can write this code, is not working out. Most of the links I saw for "inline schema" were Microsoft-related, so maybe it's a weird Microsoft thing. That would explain why we don't have Java support for it. So here's a couple of options you could look at instead of that:

(1) Do the time-consuming step which generates the file (that would be the document containing its own schema, right?) but this time... Save a copy of the file. Use that copy for testing from now on.

(2) Get somebody else to do the programming, either in Java or in some other language, which produces your test file in a less time-consuming way.

moin roy
Greenhorn

Joined: Mar 28, 2012
Posts: 15

posted Apr 11, 2012 10:10:24

0

@Paul Clapham in my test application send the copied xml file to database but database will not updated because xml file contain have some unique number,if this number is entered previously then file will not be uploaded in database.