This is my home, welcome to my blog. There is no limit to the goodness of life. The more you experience and appreciate the goodness of life.

11/26/2010

What are ID, IDREF and IDREFS simple types in XSD?How is xs:unique used to constrain values? Give examples to explain the usage of these XSD constructs.

Before talking about ID, IDREF and IDREFS, we first look at the data types of XML Schema (as below).
A structural drawing


From this picture, the datatypes in XML Schema are divided into simple types and complex types, and simple types are separated into two groups, built-in types and user-defined types. Likewise, built-in primitive types and deriving types make up the built-in types.

Built-in primitive types have 19 kinds, such as time, date, string, float, decimal and so on. Moreover, derived types are generated by restricting built-in primitive or other built-in derived types. In the most of built-in primitive types, only string type and decimal type derive other types.

But now we only pay attention to derived types from string type, hierarchical chart as follows:

Derived from token type, their definition are same as the duplicate attribute in DTD. The ID, IDREF and IDREFS are used to constrain identity.

ID type is used to uniquely identify the elements of XML document. ID attribute value of specific element must unique in whole file.

IDREF and IDREFS attribute values must have the same restrictions as the ID type, and have the same value with ID attribute values. In other words, IDREF and IDREFS attribute values are not point to ID attribute values which do not exist. The difference is IDREFS is allowed to have multiple values which are separated by spaces. So in IDREFS type, space is legitimate.

Meanwhile, XML Schema provides three categories of identity-constraint definitions: xs:unique, xs:key and xs:keyref. The <xsd:unique> element enables us to designate a particular part of an instance document as having to contain a value, whether in the content of an element or an attribute, that is unique. But the XML 1.0 ID type is limited in scope to attribute values only. A unique value in XSD Schema can start with a number and can be of any datatype, and ID type values are not permitted to start with a number or contain space characters. Then, the value of <xs:unique> can be unique within some specified part of the document and need not be unique document-wide. But the value of ID type has to be unique across a whole document.

Let us to see an example about <xs:unique>, and the first is an XML document.

<? Xml version=’1.0’?>
<BookList>
   <Book BookID=”001”>
        <Title>HTTP Developer’s Handbook</Title>
<Author>Chris Shiflett </Author>
<ISBN>0-672-32454-7</ISBN>
</Book>
<Book BookID="002">
                   <Title> Digital Image Processing</Title>
                   <Author>Rafael C. Gonzalez </Author>
                   <ISBN>978-7-121-10207-3</ISBN>
</Book>
</BookList>

In this XML document, the BookID tag is unique.
Then, the XML schema corresponding to this XML file shows as follows:

<?xml version=”1.0”>
<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”>

<xs: element name=”BookList” type=”BookListType”>
<xs: unique name=”uniqueBookID”>
<xs: selector xpath=”Book”/ >
<xs: field xpath=”@BookID”/>
</xs:unique>
</element>

<xs: complexType name=”BookListType”>
  <xs: sequence>
   <xs: element name=”Book” type=”BookType”>
</xs: sequence>
</xs:complexType>

<xs:complexType name=”BookType”>
 <xs:sequence>
   <xs: element name=”Title” type=”xs: string”/>
<xs: element name=”Author” type=”xs: string”/>
<xs: element name=”ISBN” type=”xs: token”/>
</xs: sequence>
</xs:complexType>

</xs: schema>

As we can see from these codes, the scope of application of the <xs: unique> element is defined by the subelements <xs: selector> and <xs: field> which possess an xpath attribute. The value of the xpath attribute of the <xs: selector> element implies that <Book> element applies the <xs: unique> element. And the value of the xpath attribute of the <xs: field> element is BookID which is the focus of the <xs: unique> element.

The ID and IDREF/IDREFS datatypes are restricted in the extent to which they can represent relational database structures, but their relationship relates to an entire file. The <xs: key> or <xs: keyref> relationship applies xpath to locate paths, thus allowing a processor to focus on accessing only correlative parts of a document.
Finally, let’s take a look at the <xs: key> and <xs: keyref> elements. And the XML file as below:

<?xml version="1.0" encoding="UTF-8"?>
<Library>  
 <BookList>
   <Book BookID=”001”>
        <Title>HTTP Developer’s Handbook</Title>
<Author>Chris Shiflett </Author>
<ISBN>0-672-32454-7</ISBN>
</Book>
<Book BookID="002">
                   <Title> Digital Image Processing</Title>
                   <Author>Rafael C. Gonzalez </Author>
                   <ISBN>978-7-121-10207-3</ISBN>
</Book>
<Book BookID="003">
                   <Title> XML Schema Essential</Title>
                   <Author>R. Allen Wyke </Author>
                   <ISBN>0-471-41259-7</ISBN>
</Book>

</BookList>

<StudentList>
         <Student>
                   <StudentID>01</StudentID>
                   <Name>Jane</Name>
                   <Class>MSC(CS)</Class>
                   <BorrowNumber BookID=
001>1</BorrowNumber>
                   <BorrowNumber BookID=
003>1</BorrowNumber>
         </Student>
    <Student>
                   <StudentID>02</StudentID>
                   <Name>Tom</Name>
                   <Class>CA</Class>
                   <BorrowNumber BookID=
002>1</BorrowNumber>
         </Student>
</StudentList>
</Library>

The XML schema corresponding to this XML file shows as follows:

<?xml version=”1.0”>
<xs:schema xmlns:xs=”http://www.w3.org/2001/XMLSchema”>

<xs: element name=”Library” type=”LibraryType”>
<xs: complexType>
<xs: sequence>
<xs: element name=”BookList” type=”BookListType”>
<xs: element name=”Student” type=”StudentType”>
</xs: sequence>
</xs:complexType>

<xs:keyref name=”BookIDRef” refer=”BookIDKey”>
 <xs: selector xpath=”StudentList/Student/BorrowNumber”/>
<xs: field xpath=”@BookID”>
</xs:keyref>

<xs: key name=”BookIDKey”>
<xs: selector xpath=”BookList/Book”/>
<xs: field xpath=”@BookID”/>
   </xs: key>
</xs:element>

<xs: complexType name=”BookListType”>
  <xs: sequence>
   <xs: element name=”Book” type=”BookType”>
</xs: sequence>
<xs: attribute name=”BookID” type=”xs: string”/>
</xs:complexType>
<xs:complexType name=”BookType”>
 <xs:sequence>
   <xs: element name=”Title” type=”xs: string”/>
<xs: element name=”Author” type=”xs: string”/>
<xs: element name=”ISBN” type=”xs: token”/>
</xs: sequence>
</xs:complexType>

<xs:complexType name=”StudentType”>
 <xs:sequence>
   <xs: element name=”StudentID” type=”xs: string”/>
<xs: element name=”Name” type=”xs: string”/>
<xs: element name=”Class” type=”xs: string”/>
<xs: element name=”BorrowNumber” type=”BorrowNumberType”/>
</xs: sequence>
</xs:complexType>

<xs: complexType name=”BorrowNumberType”>
  <xs: simpleContent>
   <xs: extension base=”xs: integer”>
   <xs: attribute name=”BookID” typy=”xs: string”/>
   </xs: extension>
</xs: simpleContent>
</xs: complexType>

</xs: schema>

In this XML Schema, the <xs: keyref> element also contains an <xs:selector> element and an <xs: field> element. The xpath attributes of those elements help us to locate in the <StudentList> element, or rather the BookID attribute of this element. And it possesses a name and a refer, name is defined as the name of xs: keyref as well as the refer is the name of <xs: key> element. Thereby the value in the refer attribute of the <xs:keyref> element must match the value of a name attribute of an <xs: key> element.

11/23/2010

What are the Long Tail Effect and Streisand Effect? How are they related to Web 2.0? Give real-life examples how they take place in Web 2.0 age.

The term of long tail effect originally published on ”Wired Magazine (WIRED)” by Chris Anderson in 2004, which describes business and economic models of some websites, such as Amazon, Netflix and Real.com/Rhapsody. “Head” and “tail” are two statistical terms, and the middle protruding part of normal curve is head; the relatively flat part of both sides is tail, so the mathematical basis of the long tail is uncomplicated. Now from the perspective of people’s requirement, the majority of needs concentrate on head which are called popular. However, others distributed on tail are personalized, a handful of scattered needs form a long tail on demand curve.


The long tail effect’s focus on quantity. When all non-popular market form a bigger market than the prevalent. Yet Pareto’s Law which was originally an iron rule in business is broken by this effect, due to development of the network. Internet provides widely sales level, making 98% of products can have changes to sale. While these products having long effect characteristic not only have earning values for enterprises, but also the total value of these goods can completes with best-selling products. If we want to better use this effect, we should attach importance to Web2.0 network platform. Internet lets us no longer limit by space, and reduces cost of sales. Hence through Internet, buyers and sellers can conveniently carry out a transaction.

There are an amount of successful examples of using the long tail effect.Google is a typical example. Millions of small businesses and individuals never made an advertisement before, or did it on a large scale. But Google has lowered down the threshold, since then the advertisements are not unattainable, they are self-serviced, cheap, and can be done by everybody; on the other hand, for thousands of blog sites and small-scale business websites, it's extremely easy to put advertisements on their sites. Now half of Google's business doesn't come from the advertisements put in search results, but these small websites. Millions of medium and small businesses represent a huge long tail market.

Amazon is another successful “long tail” firm. Amazon’ online bookstore possessing thousands of books, a small part occupies half of total sales volume. Most part of books, although each sale is few, relying on their variety, they hold the half sale volume.

Another key term is Streisand effect. Its origin is very interesting, which about an actress named Barbra Streisand. In 2002, Barbra Streisand unsuccessfully attempted to accuse photographer Kenneth Adelman and Pictopia.com in an attempt to remove her mansion from the publicly available collection of California coastline photographs, citing privacy concerns. As a result of the case, public knowledge of the picture increased substantially and it became popular on the Internet, with more than 420,000 people visiting the site over the following month. Unnoticed by people before, this website become famous by this reason and attract a number of people to read. 

The Streisand effect is a phenomenon that on the Internet attempting to censor or delete a couple of information unconsciously but causing the information to be widely publicized.
In other words, some people want to attempt to suppress information or comments on the network but they are not successful. Spreading through the media or the network, several unknown information become prevalent, further they create the effect of free publicity. Especially, in this age of Web 2.0, users can upload information file to the Web for public viewing, as well as people can put their photos, movies or documents on the blog.

Along with that many Streisand effect take place on the Internet. For example, management staff in Digg remove several articles concerning with HD DVD key break due to receiving a letter from lawyer of ACCS association. However, the behavior that Digg delete post cause drastic reaction among users. Meantime, password taking domain names, billboards, wallpaper and poetry form appear on wherever. Another popular instance is that the court commanded the MIT hacker to sealbut led to the leaking acceleration.

11/22/2010

卧室内绝不能摆放的11种花

  很多人喜欢在自己的卧室内养一些鲜花来进行装饰,增加美感,心情是可以理解的。养花不但使卧室漂亮,还能净化空气,对身体大有好处。不少人还不知道花不是乱养的,有很多花是对身体有害的,不但无宜,严重的还会危及生命,下面是十一种卧室内不宜养的花,一定要引起大家的注意。

兰花、百合花
 
  这两种花其香气会刺激人的神经系统,令人过度兴奋,极容易导致人失眠。

月季花

  它所散发出来的浓郁香味,会使一些人产生胸闷不适、憋气与呼吸困难。


松柏类花木

  其芳香气味对人体的肠胃有刺激作用,不仅影响食欲,还可能使孕妇感到心烦意乱、恶心呕吐。
洋绣球花

  它所散发的微粒,如与人的皮肤接触,会产生皮肤过敏反应。

夜来香

  它在夜晚会散发出大量刺激嗅觉的微粒,闻之过久,会使高血压和心脏病患者感到头晕目眩、郁闷不适,甚至病情加重。
郁金香     
  它的花朵含有一种毒碱,人若是接触过久,会加快毛发脱落。


夹竹桃

  它可以分泌出一种乳白色液体,接触时间一长,会使人中毒,引起昏昏欲睡、智力下降等症状。孕妇如果靠近它,会引起胎音异常。


狼毒、万年青
 
  它的汁液含有哑唪酶,对人体是十分不利的。如小孩误服会引发声带发肿,甚至致哑。

含羞草
 
  这种花也和郁金香花一样,人若是接触过久,可致脱发。

豹皮花
 
  它所散发出来的气味微粒,对人体也十分不好,可使人致晕。
红背桂、变叶木、虎刺梅     
  这几种花木,会与人体产生严重的不良反应,是致癌花木之一,不宜栽种。