Social networks
You can find me on:
   
Open sharing content

These articles are available under Creative Commons license BY-SA-3.0

Posts Tagged ‘root’

In this post I will show you how to represent an XSD schema with root attribute and child element with attribute and value. For example, let´s consider a software development team:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<team category="software development">
    <Member role="junior">Laura</Member>
    <Member role="senior">Erik</Member>
    <Member role="graduate">Mike</Member>
</team>

The xsd schema generally represent a a working team :

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://acme.com/schema/type/team/v1" xmlns:team="http://acme.com/schema/type/team/v1"
	xmlns:company="http://acme.com/schema/type/company/v1"
	elementFormDefault="qualified">

	<xsd:element name="Team" type="team:Team" />

	<xsd:complexType name="Team">
		<xsd:annotation>
			<xsd:documentation>Represents a working team </xsd:documentation>
		</xsd:annotation>
		<xsd:sequence maxOccurs="unbounded">
			<xsd:element name="Member">
				<xsd:complexType>
					<xsd:simpleContent>
						<xsd:extension base="xsd:string">
							<xsd:attribute name="role" type="xsd:string" />
						</xsd:extension>
					</xsd:simpleContent>
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
		<xsd:attribute name="category" type="xsd:string" />
	</xsd:complexType>
</xsd:schema>

Although it seems to be a typical case, I have spent several hours reading books, tutorials and forum, trying to map a web service xml file with such a structure.
I have finally found the solution on a google forums post.

A better solution would be using the type attribute and make a separate “complexType” tag, because in this way JAXB would be able to create a different bean class for each element (also the nested ones). So an equivalent version of the schema is the following:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://acme.com/schema/type/team/v1" xmlns:team="http://acme.com/schema/type/team/v1"
	xmlns:company="http://acme.com/schema/type/company/v1"
	elementFormDefault="qualified">

	<xsd:element name="Team" type="team:Team" />

	<xsd:complexType name="Team">
		<xsd:annotation>
			<xsd:documentation>Represents a working team </xsd:documentation>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="Member" type="team:member" minOccurs="0"
				maxOccurs="unbounded" />
		</xsd:sequence>
		<xsd:attribute name="category" type="xsd:string" />
	</xsd:complexType>
	
	<xsd:complexType name="member">
		<xsd:simpleContent>
			<xsd:extension base="xsd:string">
				<xsd:attribute name="role" type="xsd:string" />
			</xsd:extension>
		</xsd:simpleContent>
	</xsd:complexType>

</xsd:schema>

In eclipse, downloading the “m2e conntector for jaxb” plugin, you can automatically generate all the object classes from your XSD schema (in the menu bar menu you can find the JAXB section under File>New>…). Without a binding file, you will have to add the “@XmlRootElement” annotation on the top of your root element class and also delete the namespace in the package-info class. I will tell you more in the next posts…

filesystem: the files and directories (or folders), the method used to store data on the hard drive (such as the ext3 filesystem.

– Windows keeps all the important system files in a single directory C:\
– Linux follows the lead of its UNIX
– Windows and Linux setups are both logical

✓ Linux uses a forward slash (/) between directories, not the backslash (\) that Windows uses. So, the file yum.conf in the directory etc is
etc/yum.conf.

✓ Files and directories can have names up to 256 characters long, and these names can contain underscores (_), dashes (-), and dots (.) any-
where within. So my.big.file or my.big_file or my-big-file are all valid filenames.

✓ Upper- and lowercase matter. They have to match exactly. The files yum.conf and Yum.conf are not the same as far as Linux is concerned.
Linux is case-sensitive — it pays attention to the case of each character. Windows, on the other hand, is case-insensitive.

✓ The same filesystem can span multiple partitions, hard drives, and media (such as CD-ROM drives). You just keep going down through
subdirectories, not having to care whether something is on disk A, B, or whatever.

Everything in the Linux filesystem is relative to the root directory — not to be confused with the system Administrator, who is the root user. The root directory is referred to as /, and it is the filesystem’s home base — a doorway into all your files. As such, it contains a relatively predictable set of subdirectories. Each distribution varies slightly in terms of what it puts in the root directory. More or less you can find the following directories.

/bin   : Essential commands that everyone needs to use at any time.*
/boot  : The information that boots the machine, including your kernel.*
/dev :  The device drivers for all the hardware that your system needs to  interface with.*
/etc  : The configuration files for your system.*
/home  : The home directories for each of your users.
/lib  : The libraries, or the code that many programs (and the kernel) use.*
/media  : A spot where you add temporary media, such as floppy disks and  CD-ROMs; not all distributions have this directory.
/mnt  :  A spot where you add extra filesystem components such as networked drives and items you aren’t permanently adding to your filesystem but that aren’t as temporary as CD-ROMs and floppies.
/opt   : The location that some people decide to use (and some programs want to use) for installing new software packages, such as word
processors and office suites.
/proc   : Current settings for your kernel (operating system).*
/root   : The superuser’s (root user’s) home directory.
/sbin   : The commands the system Administrator needs access to.*
/srv   : Data for your system’s services (the programs that run in thebackground).*
/sys   : Kernel information about your hardware.*
/tmp   : The place where everyone and everything stores temporary files.
/usr   : A complex hierarchy of additional programs and files.
/var   : The data that changes frequently, such as log files and your mail.