-->

Sunday, November 3, 2013

Atomic,List and Union Data Types in XML Schemas

Atomic Data Types

Atomic data types cannot be broken down into smaller units. These data types can be primitive or derived. For example, the string primitive data type cannot be broken down further into smaller units, such as a characters.

List Data Types 

List data types are derived data types that contain a set of values of atomic data types elements referring to a list data type can contain a value only from that defined set. For example, you can create a list data type called pointlist, which is derived from the data type decimal and contains the following values .5, 2.5, and .75. Any element that is associated with the pointlist data type can contain only .5, 2.5, or .75 as its value.

Union Data Types

Union data types are derived from the atomic list data types. For example, if zip name is an atomic data type that can n create a data type called zips that can contain a combination of both these data types. Now, if you create an element called ZIPCODE of type zips, then ZIPCODE  element can contain the values shown in the following code snippet:

<ZIPCODE>NY</ZIPCODE>
<ZIPCODE>90547  96098 90contain only string values and zipnum is a list data type that can contain a list of zip code numbers, then you ca878 </ZIPCODE>
<ZIPCODE>CA </ZIPCODE>

Derived Data Types in XML Schemas

Introduction

Derived data types are defined by using other data types called base types. Base data types can either be primitive or derived data types. Derived data types can be built-in or user-defined. For example, integer is a built-in data type that is derived from the decimal data type.

Derived Data Types
Base Data Type
Description
Integer
Decimal
Represents a sequence of decimal digits with an optional leading sign (+ or -)
long
Integer
Represents a value within the range -9223372036854775808 to 9223372036854775807
nonNegativeInteger
Integer
Represents an integer that is greater than or equal to zero
Positive Integer
nonNegativeInteger
Represents an integer greater than zero
int
Long
Represents an integer within the range -2147483648 to 2147483747
time
recurringDuration
Represents an instance of time that recurs every day.
date
 timeDuration
Represents a time period that starts at the midnight of a particular day and ends at the next midnight.

Primitive Data Type in XML Schemas

Introduction

Primitive data type are the fundamental data types of XSD. These data types are the basis for defining other data types in XSD. Primitive data types dot not contain elements or attributes. They contain only values.

Some of the primitive data types supported by XSD are listed in the following table.

Primitive Data Type
Description
String
Represents a collection of characters.
Decimal
Represents decimal numbers. This can be used to accurately define a value.
Float
Represents single-precision 32-bit floating-point numbers
Boolean
Represents Boolean values. This data type can have a value of true or false
timeDruration
Represents certain duration of time.
RecurringDuration
Represents a time duration that recurs after a specific interval.

Advantages of XML Schemas Created Using XSD

An XML schema defines the list of elements and attributes that can be used in an XML document. In addition to the list of elements, an XML schema specifies the order in which these elements appear in the XML document, and their data types.
Microsoft has developed the XML Schema Definition(XSD) language to define the schema of an XML document. XML schema s  have now become a w3c recommendation for creating valid XML documents.

Advantages of XML Schema s Created Using XSD
Some of the advantages of creating an XML schema by using XSD are:

  • XSD provides control over the type of data that can be assigned to elements and attributes.
  • XSD enables you to create your own data types. This feature enhances the flexibility of defining the structure of the XML document.
  • XSD enables you to specify restriction on data. For example, you can ensure that the content of an element is a positive integer value.
  • The syntax for defining an XSD is the same as the syntax used for xml documents. Therefore, it is easier to learn the syntax of an XSD.
  • XML schema content models can be used to validate mixed content.
  • XML schema is extensible. This enables you to reuse parts of a schema in another schema and derive custom data types from existing data types.
  • XML schema is self documenting. Using the annotation element you can specify the intended purpose and attribute of a schema. This enables effective use of the schema by other.

Saturday, November 2, 2013

Creating an XML Document

Problem Statement

CyberShoppe, Inc. sells toys and books in the United States. It has three branches in different parts of the country. Currently, the three branches maintain data on their local computer systems. The IT manager at CyberShoppe has identified that a centralized data repository on the products sold through its e-commerce site is required. The data from all branches must be collated and housed in a centralized location. This data must be made available to the accounts and sales sections at the individual branches, regardless of the hardware and software platforms being used at the branches. In addition, the sales personnel require access to the data using palmtops and cellular phones.
The product details of CyberShoppe consists of the product name, a brief description, the price, and the available quantity on hand. A product ID uniquely identified each product.

Solution
To solve the preceding problem, you need to perform the following tasks:

  1. Identify the method to store data in a device-independent format.
  2. Identify the structure of the document in which data is to be stored.
  3. Create an XML document to store the data.
  4. View the XML document in a browser.

Task 1: Identifying the method to store the Data in a Device-Independent Format

In the given problem statement, device ranging from mainframe computers to mobile phones must be able to access information from the data store. For example, the employee of the sales department may need to access product costs using an IBM PC. XML enables different types of devices to access information. Therefore, XML can be used to create the data store in the given scenario.

Task 2 : Identifying the Structure of the Document in Which Data is to be stored.

In the given scenario, PRODUCTDATA has been Identified as the root element. It has one child element, PRODUCT. The PRODUCT element can occur one or more times in the XML document. It acts as the container element for the PRODUCTNAME , DESCRIPTION, PRICE, AND QUANTITY elements. PRODUCTNAME has one attribute called PRODID, which is used to uniquely identify each product. The following figure illustrate the structure of the elements used in the XML document to store the product data.

Creating an XML Document
Structure of the XML Document to Store Product Data

Task 3: Creating an XML Document to Store Data

To create an XML file that contains information about the products sold by CyberShoppe, type the following code in Notepad, and save the file as cyber_products.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!-- PRODUCTDATA is the root element -->
<PRODUCTDATA>
<PRODUCT PRODID="P001">
<PRODUCTNAME>Barbie Doll</PRODUCTNAME>
<DESCRIPTION>This is a toy for children in the age group of 5-10 years </DESCRIPTION>
<PRICE>12</QUANTITY>
</PRODUCT>
</PRODUCTDATA>

Task 4: Viewing the XML Document in a Browser

To View the XML document in the browser, open the cyber_products.xml file in Internet Explorer . IE provides a default tree view layout for an XML document. You can expand and collapse the tree.

The tree-view structure of the cyber_products.xml document is shown in the following figure

Creating an XML Document



Future of XML

XML has revolutionized the web and the nature of distributed computing. It is the preferred file format for web development, document interchange, and data interchange. Currently, news organizations and wireless services exchange news articles, stock information, and other similar information through proprietary formats. XML will enable wider use and exchange of such information in future. XML will also help global businesses exchange data in a customized and universally acceptable format.
The future uses of XML can be summarized as:

  • XML will be widely used in e-commerce.
  • XML will have a huge core market in the form of B2B.
  • XML will be used for mobile devices, such as mobile phones, PDAs, and palmtops due to its ability to easily convert into the appropriate format for any device.
  • XML will be used to solve communication problems in EDI and Enterprise Application Integration(EAI) as it provides interoperability between disparate  applications.
Lets us look at some real life examples of XML implementation.
identifying Real-Life implementation of XML 
The Microsoft site, http://msdn.microsoft.com/xml/, provides information about customers who have successfully implemented XML in real-life. A few of these customers are listed as follows:
  • FreeEDGAR.com, Inc. is an organization that provides updated information on finance, institutional holdings, and insider trading patterns to its customers. To provide this information, FreeEDGAR.com uses an XML based delivery service. This service is based on real-time filling from the US securities and Exchange commission. One of the project requirements was that FreeEDGAR's customers should be able to use the service on multiple platforms. The service had to be independent of any database technology. FreeEDGAR also had to ensure are able to query and access the structured information easily. The development team realized that XML was the perfect solution for its project's requirements. The team used a processing server and built its XML service on top of it. To generate Web Pages, it used MSXML DLL along with some XSL style sheets that were used to convert XML into HTML. The team used MSXML inside a Web page created using Visual InterDev and Visual Basic components. This approach reduced code maintenance and resulted in the development of more readable code.
  • Shopping.com is another example of the real life implementation of XML. Shopping.com uses context based shopping to ensure that its uses get relevant results for their searches. The organization had to ensure that the users who conduct keyword searches through AltaVista Search also receive suitable product offers from Shopping.com for example, The keyword , "CD player", on AltaVista Search will return Web search results along with relevant CD players and electronics merchandise available for purchase from shopping.com. The development team faced the challenge of ensuring quick transfer of data between two different operating systems. Since the XML syntax is simple to learn and can be used quickly , they decided to use XML for the project. The use of XML enabled them to reduce the size of the data file and the time taken to transfer the data file to a great extent.

Programmatically change CheckBoxList text color in ASP.NET

Introduction

If you want to change foreColor of the font for better visibility then you must change font color according to users. Highly rich content website change font color , font name/face and font size according to users. Get lots of visitors or viewers from your website  using website functionality (better presentation, better look and better theme) .

lets take an simple example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckBoxListFont.aspx.cs" Inherits="CheckBoxListFont" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:CheckBoxList ID="CheckBoxList1" runat="server" Height="45px" Width="239px">
            <asp:ListItem>Adrotator</asp:ListItem>
            <asp:ListItem>BulletedList</asp:ListItem>
            <asp:ListItem>Button</asp:ListItem>
            <asp:ListItem>CheckBox</asp:ListItem>
        </asp:CheckBoxList>
        <br />
        <asp:Button ID="Button1" runat="server" Height="35px" onclick="Button1_Click"
            Text="Change forecolor" Width="119px" />
   
    </div>
    </form>
</body>

</html>
Codebehind

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class CheckBoxListFont : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        CheckBoxList1.ForeColor = System.Drawing.Color.Red;


    }
}
Output
Programmatically change CheckBoxList text color in ASP.NET

Programmatically change CheckBoxList text color in ASP.NET

© Copyright 2013 Computer Programming | All Right Reserved