• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to add xml schema within xml using jaxb

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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.

I try to do this using writing some code looks like
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

arjun ray wrote:@Paul Clapham I receive your answer on previous thread but you give me your reply by using dom4j...



That wasn't my reply, that was somebody else's reply.
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That was me.

One technology may not handle everything.

Learn to mix-and-match to achieve your desired result.

Pat.
 
moin roy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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.
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I went through the posts. What I am not able to understand is why you want to include the Schema as well in the generated XML.

Regards,
Amit
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Totally agree with Amit here. Why do you want to add the schema to the XML that was generated from it?
 
moin roy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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.

 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

if I delete the schema part of the generated file then it will unable to update the database.



Why does updating the database depend upon the presence of the schema?
 
James Boswell
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The standard for a schema reference within XML is to use the xsi:schemaLocation attribute. Never have I seen the need to inline the entire schema itself.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like it's option (2) then.
 
moin roy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Paul Clapham thanks for your escape solution.
 
pie. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic