Sunday, November 13, 2011

Different Test Style By Java Script.

Hi,
Java script provide different in built function for editing the output of Test Format like.
<html>
<body>

<script type="text/javascript">

var txt = "Hello World!";

document.write("<p>Big: " + txt.big() + "</p>");
document.write("<p>Small: " + txt.small() + "</p>");

document.write("<p>Bold: " + txt.bold() + "</p>");
document.write("<p>Italic: " + txt.italics() + "</p>");

document.write("<p>Fixed: " + txt.fixed() + "</p>");
document.write("<p>Strike: " + txt.strike() + "</p>");

document.write("<p>Fontcolor: " + txt.fontcolor("green") + "</p>");
document.write("<p>Fontsize: " + txt.fontsize(6) + "</p>");

document.write("<p>Subscript: " + txt.sub() + "</p>");
document.write("<p>Superscript: " + txt.sup() + "</p>");

document.write("<p>Link: " + txt.link("http://www.w3schools.com") + "</p>");

document.write("<p>Blink: " + txt.blink() + " (does not work in IE, Chrome, or Safari)</p>");

</script>

</body>
</html>

Just try this and I hope you will got some new.

Wednesday, November 9, 2011

How to convert Xml in to Html (xHtml)

Hi today i got the idea how we can convert our xml page in to xhtml . Its quit simple as just like  css style sheet is uses to decorate html page.
The major different in the process just here we are use xsl (xml style sheet ) instead css. This can be done by the help of  Xslt (xml style sheet transformation ).
Here i am post the example (Its a xml page where we give href relation with xsl plae like.

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<catalog>
  <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
  </cd>
</catalog>
And the code of  cdcatalog.xsl is here
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
  <body>
  <h2>My CD Collection</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Title</th>
      <th>Artist</th>
    </tr>
    <xsl:for-each select="catalog/cd">
    <tr>
      <td><xsl:value-of select="title"/></td>
      <td><xsl:value-of select="artist"/></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
The reference of style sheet already given in the top header of xml page.

 <xsl:template match="/"> :-- Describe that we are apply style sheet in whole xml page due to match attribute match="/"


<xsl:for-each select="catalog/cd"> :-- Its reach all the nodes under the catalog .

Hi.... an another example of Converting xml in to Html
My Student.xml page code
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="student.xsl"?>

<student>
          <Roll_number>
                        <Name>Deepak Sharma</Name>
                        <Class>5th</Class>
                        <Year>2010</Year>  
          </Roll_number>
          <Roll_number>
                        <Name>Arun Sharma</Name>
                        <Class>5th</Class>
                        <Year>2011</Year>  
          </Roll_number>
          <Roll_number>
                        <Name>Mohit Sharma</Name>
                        <Class>5th</Class>
                        <Year>2010</Year>  
          </Roll_number>

</student>
Just check it that i have already mention student.xsl in there head session.
The code of student.xsl is.....
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
          <table><tr>
                 <th>Name</th><th>Class</th></tr>
                  <xsl:for-each select="student/Roll_number">
                 <tr><td><xsl:value-of select="Name"/></td><td><xsl:value-of select="Year"/></td></tr>
                 </xsl:for-each>
          </table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The xml style sheet flow chat like that....
1.<xsl:stylesheet version="" href="" ?></xsl:stylesheet>
2.<xsl:template></xsl:template>
3.<xsl:for-each></xsl:for-each>
4.<xsl:value-of select="">
Thanks




Tuesday, November 8, 2011

What is Xml NameSpace

Hi
I am start with some xml example let check this out......
<table>
  <tr>
    <td>Apples</td>
    <td>Bananas</td>
  </tr>
</table>
And another example of xml is
<table>
  <name>African Coffee Table</name>
  <width>80</width>
  <length>120</length>
</table>
As per the example both xml tag start with Table tag . so when we combined to gather there may be the chance of conflict.
An XML parser will not know how to handle these differences.

We can resolve the problem by Tar prefix like 
<h:table>
  <h:tr>
    <h:td>Apples</h:td>
    <h:td>Bananas</h:td>
  </h:tr>
</h:table>

<f:table>
  <f:name>African Coffee Table</f:name>
  <f:width>80</f:width>
  <f:length>120</f:length>
</f:table> 
The namespace is defined by the xmlns(xml namespace) attribute in the start tag of an element.
The namespace declaration has the following syntax. xmlns:prefix="URI".

<h:table xmlns:h="http://www.w3.org/TR/html4/">
  <h:tr>
    <h:td>Apples</h:td>
    <h:td>Bananas</h:td>
  </h:tr>
</h:table>

<f:table xmlns:f="http://www.w3schools.com/furniture">
  <f:name>African Coffee Table</f:name>
  <f:width>80</f:width>
  <f:length>120</f:length>
</f:table>
When a namespace is defined for an element, all child elements with the same prefix are associated with the same namespace.
Namespaces can be declared in the elements where they are used or in the XML root element:
<root
xmlns:h="http://www.w3.org/TR/html4/"
xmlns:f="http://www.w3schools.com/furniture"
>

<h:table>
  <h:tr>
    <h:td>Apples</h:td>
    <h:td>Bananas</h:td>
  </h:tr>
</h:table>

<f:table>
  <f:name>African Coffee Table</f:name>
  <f:width>80</f:width>
  <f:length>120</f:length>
</f:table>

</root> 

Namespaces in Real Use

XSLT is an XML language that can be used to transform XML documents into other formats, like HTML.
In the XSLT document below, you can see that most of the tags are HTML tags.
The tags that are not HTML tags have the prefix xsl, identified by the namespace xmlns:xsl="http://www.w3.org/1999/XSL/Transform":

Thanks It all about xml namespace . I will  post further in our next session.