Bits and Bytes

Learn to Live

XSL Questions and Solutions in XML — January 29, 2011

XSL Questions and Solutions in XML

Q1.For the below xml, create an xsl which displays only the text “24X7 news” when applied to the below xml.

News.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="News.xsl" ?>
<news>
   <news_item>
        <title>Title</title>
        <content>
           <par>
               This is My News
               <footnote>toi</footnote>
          </par>
        </content>
       <date>19/01/11</date>
        <author>Anki</author>
        <news_agent>TOI</news_agent>
    </news_item>
</news>

Solution

The xsl for the above xml

News.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="news_item">
     <html>
       <h1>24x7 News</h1>
    </html>
</xsl:template>
</xsl:stylesheet>


Open the XML file in a browser. The o/p is shown below

News1

Q2. Modify the xsl, to print the title, date and author of the news item in a tabular format.

Solution

News2.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="news_item">
   <html>
        <br/>
        <table border="1" align="center" cellpadding="10">
         <tr>
           <th>Title</th>
           <th>Date</th>
           <th>Author</th>
         </tr>
         <tr>
             <td><xsl:value-of select="title"/></td>
              <td><xsl:value-of select="date"/></td>
              <td><xsl:value-of select="author"/></td>
         </tr>
      </table>
     </html>
</xsl:template>
</xsl:stylesheet>


To link an XML file with a XSL add this line

Here in News.xml file we added this line

<?xml-stylesheet type=”text/xsl” href=”News2.xsl” ?>

Open this file in a Browser

o/p

News2

Vitamin D Deficiency Can Be Fatal —

Vitamin D Deficiency Can Be Fatal

Lung (PSF)
Image via Wikipedia

Vitamin D deficiency has been shown to alter lung structure and function in a new study in young mice.

The new study, conducted by researchers in Australia, offers the first concrete evidence linking vitamin D deficiency with deficits in lung function and altered lung structure.

“The results of this study clearly demonstrate that vitamin D deficiency alters lung growth, resulting in lower lung volume and decrements in lung function,” said Graeme Zosky, a research fellow at the Telethon Institute for Child Health Research in Subiaco, Australia.

“This is the first direct mechanistic evidence showing that vitamin D deficiency alters lung development, which may explain the association between obstructive lung disease and levels of vitamin D.”

To conduct their study, the researchers used a mouse model of vitamin D deficiency and evaluated lung responses of two-week-old mice, comparing them to control mice without vitamin D deficiency to determine what, if any, effects the deficiency may have caused in the growth, structure or function of the lungs.

8051 Microcontroller — January 28, 2011

8051 Microcontroller

What is microcontroller?

A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications.

Intel MCS-51 or 8051

The Intel MCS-51 is a Harvard architecture, single chip microcontroller (µC) series which was developed by Intel in 1980 for use in embedded systems.

Overview of the 8051

  • Made by Intel in 1981
  • An 8-bit, single-chip microcontroller optimized for control applications
  • 128 bytes RAM, 4096 bytes (4KB) ROM, 2 timers, 1 serial port, 4 I/O ports
  • 40 pins in a dual in-line package (DIP) layout

General Physical Features

  • 4KB ROM

  • 128 bytes internal RA

  • 4 register banks of 8 bytes each (R0-R7)

  • 16 bytes of bit-addressable area

  • 80 bytes of general purpose memory

  • Four 8-bit I/O ports (P0-P3)

  • Two 16-bit timers (Timer0 & Timer1)

  • One serial receiver-transmitter interface

  • Five interrupt sources (2 external & 3 internal)

  • One oscillator (generates clock signal)

The 8051 Block Diagram

8051BlockDiagram

The 8051 Pin Assignments



Pinout Description

Pins 1-8: Port 1 Each of these pins can be configured as an input or an output.

Pin 9: RST A logic one on this pin disables the microcontroller and clears the contents of most registers. In other words, the positive voltage on this pin resets the microcontroller. By applying logic zero to this pin, the program starts execution from the beginning.

Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or output. Besides, all of them have alternative functions:

Pin 10: RXD Serial asynchronous communication input or Serial synchronous communication output.

Pin 11: TXD Serial asynchronous communication output or Serial synchronous communication clock output.

Pin 12: INT0 Interrupt 0 input.

Pin 13: INT1 Interrupt 1 input.

Pin 14: T0 Counter 0 clock input.

Pin 15: T1 Counter 1 clock input.

Pin 16: WR Write to external (additional) RAM.

Pin 17: RD Read from external RAM.

Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies operating frequency is usually connected to these pins. Instead of it, miniature ceramics resonators can also be used for frequency stability. Later versions of microcontrollers operate at a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground.

Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are configured as general inputs/outputs. In case external memory is used, the higher address byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb is not used, which means that not all eight port bits are used for its addressing, the rest of them are not available as inputs/outputs.

Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears on it every time the microcontroller reads a byte from memory.

Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip) memorizes the state of P0 and uses it as a memory chip address. Immediately after that, the ALU pin is returned its previous logic state and P0 is now used as a Data Bus. As seen, port data multiplexing is performed by means of only one additional (and cheap) integrated circuit. In other words, this port is used for both data and address transmission.

Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address transmission with no regard to whether there is internal memory or not. It means that even there is a program written to the microcontroller, it will not be executed. Instead, the program written to external ROM will be executed. By applying logic one to the EA pin, the microcontroller will use both memories, first internal then external (if exists).

Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0).

Pin 40: VCC +5V power supply.

Sleep Well Live Well — January 27, 2011

Sleep Well Live Well

Main complications of insomnia (See Wikipedia:...
Image via Wikipedia

If you woke up this morning feeling grumpy and fed up because you didn’t sleep well, you weren’t the only one.

Almost two thirds of us struggle to get a good night’s rest, according to research. The problem has become so bad, experts say it constitutes a major public health concern.

Some 60 per cent of adults admit they have a sleep problem and rarely get the recommended six or seven hours a night.

More than a third suffer from insomnia, and many have battled with the condition for years. Doctors warn that sleeplessness leads to depression, lack of concentration and an inability to carry out simple tasks.

According to the findings of a major report, insomniacs are four times more likely to suffer from relationship problems. They are also three times more likely to have difficulties concentrating or be in a bad mood and twice as likely to have energy slumps.

A quarter of adults have other sleep-related problems such as teeth grinding or sleep apnea – a disorder characterised by abnormal pauses in breathing which causes sufferers to wake up in the night.

Just 39 per cent of us sleep well, according to the survey of 5,300 by the Mental Health Foundation. It is calling for sleep campaigns to make the public more aware of the importance of getting a good night’s rest.

Read more: http://www.dailymail.co.uk/news/article-1350914/Sleep-deprivation-2-3-dont-good-nights-sleep.html#ixzz1CGJgllNw

Positive Approach —
Busy January —
Happy 62nd Republic Day :) — January 25, 2011
Bill Gates Pic at SICSR_Pune — January 24, 2011
Health Checkup Day —

Health Checkup Day

Done with my health checkup finally…..

ENT, OPD, Dental, X-Rays, Sonography, Physician, Blood etc etc…

And that too at 8:30 in the morning…

🙂 😉

It was difficult but I did it…Health Checkups r important Fearing from them is useless. 🙂

Health is Wealth 😀

 

Funny Indian Boy and his Teacher — January 23, 2011