cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding Datatype Creation

Former Member
0 Kudos

Hello Experts,

While creating Data type we will have three types of elements, they are like

1) Insert element

2) Insert Sub element

3) Insert Attribute

Why do we go for these different kinds?

thank you

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

thank you

Former Member
0 Kudos

Element:

An XML element is everything from (including) the element's start tag to (including) the element's end tag.

An element can contain other elements, simple text or a mixture of both. Elements can also have attributes.

Example:

<bookstore>

<book category="CHILDREN">

<title>Harry Potter</title>

<author>J K. Rowling</author>

<year>2005</year>

<price>29.99</price>

</book>

<book category="WEB">

<title>Learning XML</title>

<author>Erik T. Ray</author>

<year>2003</year>

<price>39.95</price>

</book>

</bookstore>

Insert Element

For the above example, you can create the element <book>, using Insert Element.

Insert attribute:

<book> has an attribute u2018categoryu2019.You can create this using u2018Insert attributeu2019

Insert Subelement:

Under <book>, we have 4 sub elements (title,author,year,price).

You can create these sub elements using u2018Insert Subelementu2019.

Attribute:

Attributes provide additional information about elements

Example:

<file type="gif">computer.gif</file>

Attributes often provide information that is not a part of the data. In the example, the file type is irrelevant to the data, but important to the software that wants to manipulate the element.

XML Elements vs. Attributes

Take a look at these examples:

Gender as Attribute

<person gender="female">

<firstname>Anna</firstname>

<lastname>Smith</lastname>

</person>

Gender as Element

<person>

<gender>female</gender>

<firstname>Anna</firstname>

<lastname>Smith</lastname>

</person>

In the first example gender is an attribute. In the last, gender is an element. Both examples provide the same information.

There are no rules about when to use attributes and when to use elements

Some of the problems with using attributes are:

u2022 attributes cannot contain multiple values (elements can)

u2022 attributes cannot contain tree structures (elements can)

u2022 attributes are not easily expandable (for future changes)

Attributes are difficult to read and maintain. Use elements for data. Use attributes for Metadata

Former Member
0 Kudos

Hi Ravi,

we are creating data types to have some structure. In that we are maintaining the fields and values in the respective place based on our requirement and mapping. So to maintaing the level we are using the three types of terms.

element: if u click this u can see element in the category tab. u r creating a element here.

subelement: if u create one element will be added to the next level of the previous element

attribute: it is called properties.

Former Member
0 Kudos

Hi Ravi,

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_TEST xmlns:ns0="http://Sample">

<ELT1>

<FIELD1 AT1="A1">FIELD1</FIELD1>

</ELT1>

<ELT2>

<FIELD2>FIELD1</FIELD2>

</ELT2>

</ns0:MT_TEST >

The explanation for Insert Element, Insert SubElement and Insert Attribute options is shown using the above xml.

To create ELT1, you need to select Insert SubElement at DT_TEST node as it is under the DataType Name.

To create ELT2, you need to select Insert Element at ELT1 node as it is at the same level as ELT1

To create FIELD1 and FIELD2, you need to select Insert SubElement at ELT1 and ELT2 resp.

To create AT1, attribute of FIELD1, select Insert Attribute at FIELD1 node.

Hope this clarifies.

GabrielSagaya
Active Contributor
0 Kudos

Hi

For eg

<Record>

<OS lang="EN">Windows</OS>

</Record>

Here Record and OS are elements and lang is attribute.Also OS is subelement under Record.

Elements contains information as an independent field, while attributes are those which contains data about that element means its meta data.

Former Member
0 Kudos

Hi Ravi,

Please find the below link

Thanks

Sudharshan

Former Member
0 Kudos

Hi,

1) Insert element is used to create the Upper level node

2) Insert Sub element is used to create sub level elements( Fields) to the Uppser node

Difference between Element and Attribute

Regards

Seshagiri