473,441 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

How to add xml schema attributes using JAXB?

Hi,

I have to add xml schema attributes into the java object.
Such as, my java object is User. This User object will be
represented as XML using JAXB. I generated XML
from User object successfully using JAXB. But I want to add xml schema attributes. For example:

<User
xmlns="http://testws/rest/schema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://testws/rest/user UserSchema.xsd">
</User>

How do I add xmlns, xmlns:xsi, xsi:schemaLocation attributes in the User (root) element, using JAXB?
I tried with @xmlSchema annotation but it threw the following error:
Package annotations must be in file package-info.java

I would be grateful, if someone help me to solve this issue.
Jul 21 '10 #1
1 5096
Hmmm, I understood nobody knows answer of my question. However, I overcome the problem. I just take out the jaxb api and I have used StaX now. StaX is cool because it gives me to work low level task such I can now attache my multiple external schemes with the parser and writer. I have successfully achieved my goal using StaX.
Aug 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: kelvSYC | last post by:
Is it possible to make an attribute required, optional, or forbidden depending on the value of another attribute? How about changing element content based on an attribute? -- I am only a...
1
by: Wallace | last post by:
Hi all, I have a problem on validating a xml fragment using a single namespace schema which spread across multiple schema files using include in the master schema file. No matter how I change...
1
by: Whoever | last post by:
See below. The WSDL looks good, the result is OK but not Schema. Where and how should I put it in. Hopfully not manually. Thanks. public class aUser { public string UserID { get {...} set...
1
by: Kenny Ho | last post by:
Hi, I have written the following schema that contains the XML signature: ----------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?>...
0
by: aruna.hcu | last post by:
using jaxb i need to parse an xml file by DOM and get values into a java bean
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
3
by: Marc Hebert | last post by:
I'm trying to figure out if something is possible to specify and constrain using a schema. I'll explain using an example. sample xml: <person name="John" age="32"/> <person name="Julie"...
0
by: malsh1358 | last post by:
Hi I need check required elements and attributes in JAXB java classes , if there are any value for them place it , otherwise place default value in xml file , because of it I upgrade JAXB2.0 to...
4
by: javatoil260309 | last post by:
Hi all, I have using JAXB to generate XML from a XSD file. So far so good. But i noticed that all the URL's (namespaces in the xsd) are not present in the generated xml. TO be precise my XSD file...
0
by: kokababu | last post by:
Hi, I have to add xml schema attributes into the java object. Such as, my java object is User. This User object will be represented as XML using JAXB. I generated XML from User object...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.