Skip to main content

XML Attributes

From HTML you will remember this: < IMG SRC="comp.gif" >. The SRC attribute provides additional information about the IMG element. In HTML (and in XML) attributes provide additional information about elements:

< img src="computer.gif" >
< a href="demo.asp" >

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

< file type="gif" > computer.gif < /file >
Students now u know abt basic XML, its scripting rules. Lets understand XML attributes which can be understood as property of an element.

Here are simple rules for XML elements

Quote Styles, "female" or 'female'?
Attribute values must always be enclosed in quotes, but either single or double quotes can be used. For a person's sex, the person tag can be written like this:

< person sex="female" > or like this:
< person sex='female' >

Note: If the attribute value itself contains double quotes it is necessary to use single quotes, like in this example:

< Inspector name='George "Rain" Abslum' >

Note: If the attribute value itself contains single quotes it is necessary to use double quotes, like in this example:

< Inspector name="George 'Rain' Abslum" >

Use of Elements vs. Attributes: Data can be stored in child elements or in attributes.

E.g. Take a look at these examples:

< firstname > Anna < /firstname >
lastname > Smith < /lastname >
< /person >
< person >
< sex > female < /sex >
< firstname > Anna > /firstname >
< lastname > Smith > /lastname >
< /person >

In the first example sex is an attribute. In the last, sex is a child element. Both examples provide the same information. There are no rules about when to use attributes, and when to use child elements. My experience is that attributes are handy in HTML, but in XML you should try to avoid them. Use child elements if the information feels like data.

E.g.Storing data in child elements.

The following three XML documents contain exactly the same information:
A date attribute is used in the first example:
< note date="12/11/2002" >
< to > Tove < /to >
< from>Jani < /from >
< heading>Reminder < /heading >
< body>Don't forget me this weekend! < /body >
< /note >

A date element is used in the second example:

< note >
< date > 12/11/2002 < /date >
< to > Tove < /to >
< from>JaniReminder < /heading >
< body>Don't forget me this weekend! < /body >
< /note >
An expanded date element is used in the third: (THIS IS MY FAVORITE):

< note >
< date >
< day > 12 < /day >
< month > 11 < /month >
< year > 2002 </year >
< /date >
< to > Tove < /to >
< from > Jani < /from >
< heading > Reminder < /heading >
< body >Don't forget me this weekend! < /body >
< /note >

Comments

Popular posts from this blog

Advantages and Disadvantages of EIS Advantages of EIS Easy for upper-level executives to use, extensive computer experience is not required in operations Provides timely delivery of company summary information Information that is provided is better understood Filters data for management Improves to tracking information Offers efficiency to decision makers Disadvantages of EIS System dependent Limited functionality, by design Information overload for some managers Benefits hard to quantify High implementation costs System may become slow, large, and hard to manage Need good internal processes for data management May lead to less reliable and less secure data

Inter-Organizational Value Chain

The value chain of   a company is part of over all value chain. The over all competitive advantage of an organization is not just dependent on the quality and efficiency of the company and quality of products but also upon the that of its suppliers and wholesalers and retailers it may use. The analysis of overall supply chain is called the value system. Different parts of the value chain 1.  Supplier     2.  Firm       3.   Channel 4 .   Buyer

Big-M Method and Two-Phase Method

Big-M Method The Big-M method of handling instances with artificial  variables is the “commonsense approach”. Essentially, the notion is to make the artificial variables, through their coefficients in the objective function, so costly or unprofitable that any feasible solution to the real problem would be preferred, unless the original instance possessed no feasible solutions at all. But this means that we need to assign, in the objective function, coefficients to the artificial variables that are either very small (maximization problem) or very large (minimization problem); whatever this value,let us call it Big M . In fact, this notion is an old trick in optimization in general; we  simply associate a penalty value with variables that we do not want to be part of an ultimate solution(unless such an outcome is unavoidable). Indeed, the penalty is so costly that unless any of the  respective variables' inclusion is warranted algorithmically, such variables will never be p