File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Question on a proper xml namespace in order to get a specific package namespace from SDO? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Question on a proper xml namespace in order to get a specific package namespace from SDO?" Watch "Question on a proper xml namespace in order to get a specific package namespace from SDO?" New topic
Author

Question on a proper xml namespace in order to get a specific package namespace from SDO?

Mark Curlette
Ranch Hand

Joined: May 26, 2011
Posts: 46


I am new to XML targetnamespace , and I would like to get your help on how to create a proper targetNamespace in order to get a specific package namespace for the generated object from the SDO generator.


I like to have a specific package namespace like "coderanch.programming.example" for "FirstLesson.java" when i generate my student.xsd, Please check for me to see if it is

ok if I declared as following targetNameSpace in my student.xsd :




and my xml is as follow :




My problem is that I have an error in my XSD which saiud the prefix xsd in the schema:xsd is not bound.


Mark Curlette
Ranch Hand

Joined: May 26, 2011
Posts: 46

Please disregard the previous error message because I just fixed it. The new errors I got this time are the following :

1. Type reference studentType is unresolved.

2. Element reference student is unresolved.

Please let me know if you know the cause of the errors.

Thank you so much
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 539
    
    3
First the xml would not be validate according to the xsd. Second the xsd itself is not valid.

If you want the students, student, firstname etc etc be in the targetNamespace, you need to put it there in your data xml document. As such it is in a null namespace and would never be valid according to the sketched xsd.

But the xsd itself is invalid and the schema processor would not be able to resolve the type attributes and the ref attribute because they have to be qualified names. As such, they are referencing a null namespace schema and that is nowhere found: hence, unable to resolve them.

Furthermore, you want the local elements (firstname, ...) being in the targetNamespace as well, you have to instruct the xsd processor the same by elementFormDefault attribute as shown below. The proper reference of type and ref attribute are salvaged adding a default namespace in the xsd with uri being equal to the targetNamespace's uri. By that you need to change least.

All these are rather involved that you might not understand at first glance. Look at each modification carefully, each modification is meaningful and have material impact on the process.

[1] student.xsd

[2] The data xml document.
Mark Curlette
Ranch Hand

Joined: May 26, 2011
Posts: 46

Thank for your help yesterday.
I tried the example, but it gave two unresolved errors on line 8 and line 12 of the student.xsd.

Error line 8 said xsd: Type reference 'http://http://coderanch.programming.example/FirstLesson#studentType' is unresolved.

Error on line 12 said xsd: Element reference 'http://http://coderanch.programming.example/FirstLesson#student' is unresolved.

So one error refers to Type reference and another refers to element reference.

I am trying to figure out what the errors meant. So please give me some hints if you know the cause of having those errors.

Thanks so much in advance.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 539
    
    3
So one error refers to Type reference and another refers to element reference.

You have not followed the changes quite literally - that I would deduce - or that you might here or there think you could do differently that is somewhat equivalent whereas that is not in fact equivalent. In that regard, I have nothing to change.
Mark Curlette
Ranch Hand

Joined: May 26, 2011
Posts: 46

Sorry, it was my fault.

I read your comments , code again and got it resolved.

Thank you very much.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question on a proper xml namespace in order to get a specific package namespace from SDO?