How to run .exe application in remote system from your system

Guys,

Wondered how to run an application that existed somewhere remotely from here in your command prompt?

Its literally simple..lets see how we can do that..

Foremost you need to know what is windows sysinternals??

Please visit this site to know more

Steps:

1. Download it and extract the files. Now you can see list of files like below referred image

28-03-2014 13-15-16

2. Now copy these files to C:\Windows\System32

3. Now open cmd(in administrator mode) and type the following

psexec -i -s -d \\10.10.11.123 -u domain\username -p password notepad  \\ this opens notepad

psexec -i -s -d \\10.10.11.123 -u domain\username -p password calc        \\ this opens calculator

Explanation on usage:

Usage: psexec [\\computer[,computer2[,…] | @file]][-u user [-p psswd][-n s][-r servicename][-h][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,…] cmd [arguments]

-a Separate processors on which the application can run with commas where 1 is the lowest numbered CPU. For example, to run the application on CPU 2 and CPU 4, enter: “-a 2,4”
-c Copy the specified program to the remote system for execution. If you omit this option the application must be in the system path on the remote system.
-d Don’t wait for process to terminate (non-interactive).
-e Does not load the specified account’s profile.
-f Copy the specified program even if the file already exists on the remote system.
-i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session.
-h If the target system is Vista or higher, has the process run with the account’s elevated token, if available.
-l Run process as limited user (strips the Administrators group and allows only privileges assigned to the Users group). On Windows Vista the process runs with Low Integrity.
-n Specifies timeout in seconds connecting to remote computers.
-p Specifies optional password for user name. If you omit this you will be prompted to enter a hidden password.
-r Specifies the name of the remote service to create or interact with.
-s Run the remote process in the System account.
-u Specifies optional user name for login to remote computer.
-v Copy the specified file only if it has a higher version number or is newer on than the one on the remote system.
-w Set the working directory of the process (relative to remote computer).
-x Display the UI on the Winlogon secure desktop (local system only).
-priority Specifies -low, -belownormal, -abovenormal, -high or -realtime to run the process at a different priority. Use -background to run at low memory and I/O priority on Vista.
computer Direct PsExec to run the application on the remote computer or computers specified. If you omit the computer name, PsExec runs the application on the local system, and if you specify a wildcard (\\*), PsExec runs the command on all computers in the current domain.
@file PsExec will execute the command on each of the computers listed in the file.
cmd Name of application to execute.
arguments Arguments to pass (note that file paths must be absolute paths on the target system).
-accepteula This flag suppresses the display of the license dialog.

You can enclose applications that have spaces in their name with quotation marks e.g.

psexec \\marklap”c:\long name app.exe”

The following command launches an interactive command prompt on \\marklap:

psexec \\marklap cmd

This command executes IpConfig on the remote system with the /all switch, and displays the resulting output locally:

psexec \\marklap ipconfig /all

This command copies the program test.exe to the remote system and executes it interactively:

psexec \\marklap -c test.exe

Specify the full path to a program that is already installed on a remote system if its not on the system’s path:

psexec \\marklap c:\bin\test.exe

Run Regedit interactively in the System account to view the contents of the SAM and SECURITY keys::

psexec -i -d -s c:\windows\regedit.exe

To run Internet Explorer as with limited-user privileges use this command:

psexec -l -d “c:\program files\internet explorer\iexplore.exe”

What are webservices

In simple words, webservices will establish a good mode of communication with other servers. Lets say like this, we have temperature widgets everywhere(android,ios,windows etc etc). Now you want to display temperature in your widgets..will you code everywhere to show the temperature? its a very bad idea..instead you can easily call up some webservices through api’s where your api will contact to yahoo temperature server and display temperature. Here yahoo server will have a kind of method in public where receives parameters from different clients and then process and send back responses to the websites through webservices. This is how webservices will work..the same procedure will follow for cricket score updates, currency updates etc etc. Hope this is clear to get an basic idea of webservices..

web service is a method of communication that allows two software systems to exchange this data over the internet. The software system that requests data is called a service requester, whereas the software system that would process the request and provide the data is called a service provider.

Different software might be built using different programming languages, and hence there is a need for a method of data exchange that doesn’t depend upon a particular programming language. Most types of software can, however, interpret XML tags. Thus web services can use XML files for data exchange.

Rules for communication between different systems need to be defined, such as:

  • How one system can request data from another system
  • Which specific parameters are needed in the data request
  • What would be the structure of the data produced. Normally, data is exchanged in XML files, and the structure of the XML file is validated by an .xsd file.
  • What error messages to display when a certain rule for communication is not observed, to make troubleshooting easier

All of these rules for communication are defined in a file called WSDL (Web Services Description Language), which has the extension .wsdl.

Web services architecture: the service provider sends a WSDL file to UDDI. The service requester contacts UDDI to find out who is the provider for the data it needs, and then it contacts the service provider using the SOAP protocol. The service provider validates the service request and sends structured data in an XML file, using the SOAP protocol. This XML file would be validated again by the service requester using an XSD file.

A directory called UDDI (Universal Description, Discovery and Integration) defines which software system should be contacted for which type of data. So when one software system needs one particular report/data, it would go to the UDDI and find out which other system it can contact for receiving that data. Once the software system finds out which other system it should contact, it would then contact that system using a special protocol called SOAP (Simple Object Access Protocol). The service provider system would first of all validate the data request by referring to the WSDL file, and then process the request and send the data under the SOAP protocol.

XML Schemas

XML Schema

XML Schema is an XML-based alternative to DTD:

In general words its used to validate the XML code..for eg we need to validate some data that is in xml format before we store into our DB. Validation might include syntax, tags, data types etc. Then how you will validate it? Here comes the XML Schema..

<xs:element name=”note”><xs:complexType>
<xs:sequence>
<xs:element name=”to” type=”xs:string”/>
<xs:element name=”from” type=”xs:string”/>
<xs:element name=”heading” type=”xs:string”/>
<xs:element name=”body” type=”xs:string”/>
</xs:sequence>
</xs:complexType></xs:element>

The Schema above is interpreted like this:

  • <xs:element name=”note”> defines the element called “note”
  • <xs:complexType> the “note” element is a complex type
  • <xs:sequence> the complex type is a sequence of elements
  • <xs:element name=”to” type=”xs:string”> the element “to” is of type string (text)
  • <xs:element name=”from” type=”xs:string”> the element “from” is of type string
  • <xs:element name=”heading” type=”xs:string”> the element “heading” is of type string
  • <xs:element name=”body” type=”xs:string”> the element “body” is of type string

Everyting is wrapped in “Well Formed” XML.

XML Schemas are More Powerful than DTD

  • XML Schemas are written in XML
  • XML Schemas are extensible to additions
  • XML Schemas support data types
  • XML Schemas support namespaces

Why Use an XML Schema?

With XML Schema, your XML files can carry a description of its own format.

With XML Schema, independent groups of people can agree on a standard for interchanging data.

With XML Schema, you can verify data.

XML Schemas Support Data Types

One of the greatest strength of XML Schemas is the support for data types:

  • It is easier to describe document content
  • It is easier to define restrictions on data
  • It is easier to validate the correctness of data
  • It is easier to convert data between different data types

 

More about XML Schemas:

In a typical project many schemas will be created. The schema designer is then confronted with this issue: “shall I define one targetNamespace for all the schemas, or shall I create a different targetNamespace for each schema, or shall I have some schemas with no targetNamespace?” What are the tradeoffs? What guidance would you give someone starting on a project that will create multiple schemas?

Here are the three design approaches for dealing with this issue:

     [1] Heterogeneous Namespace Design: 
         give each schema a different targetNamespace
     [2] Homogeneous Namespace Design:
         give all schemas the same targetNamespace
     [3] Chameleon Namespace Design: 
         give the "main" schema a targetNamespace and give no 
         targetNamespace to the "supporting" schemas (the no-namespace supporting 
         schemas will take-on the targetNamespace of the main schema, just
         like a Chameleon)

To describe and judge the merits of the three design approaches it will be useful to take an example and see each approach “in action”.

Example: XML Data Model of a Company

Imagine a project which involves creating a model of a company using XML Schemas. One very simple model is to divide the schema functionality along these lines:

Company schema
   Person schema
   Product schema

“A company is comprised of people and products.”

Here are the company, person, and product schemas using the three design approaches.

[1] Heterogeneous Namespace Design

This design approach says to give each schema a different targetNamespace. Below are the three schemas designed using this design approach. Observe that each schema has a different targetNamespace.

Product.xsd

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.product.org"
            xmlns="http://www.product.org"
            elementFormDefault="unqualified">
    <xsd:complexType name="ProductType">
        <xsd:sequence>
           <xsd:element name="Type" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Person.xsd

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.person.org"
            xmlns="http://www.person.org"
            elementFormDefault="unqualified">
    <xsd:complexType name="PersonType">
        <xsd:sequence>
           <xsd:element name="Name" type="xsd:string"/>
           <xsd:element name="SSN" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Company.xsd

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.company.org"
            xmlns="http://www.company.org"
            elementFormDefault="unqualified"
            xmlns:per="http://www.person.org"
            xmlns:pro="http://www.product.org">
    <xsd:import namespace="http://www.person.org"
                schemaLocation="Person.xsd"/>
    <xsd:import namespace="http://www.product.org"
                schemaLocation="Product.xsd"/>
    <xsd:element name="Company">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Person" type="per:PersonType" 
                             maxOccurs="unbounded"/>
                <xsd:element name="Product" type="pro:ProductType" 
                             maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Note the three namespaces that were created by the schemas:

   http://www.product.org
   http://www.person.org
   http://www.company.org

[2] Homogeneous Namespace Design

This design approach says to create a single, umbrella targetNamespace for all the schemas. Below are the three schemas designed using this approach. Observe that all schemas have the same targetNamespace.

Product.xsd

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.company.org"
            xmlns="http://www.product.org"
            elementFormDefault="qualified">
    <xsd:complexType name="ProductType">
        <xsd:sequence>
           <xsd:element name="Type" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Person.xsd

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.company.org"
            xmlns="http://www.person.org"
            elementFormDefault="qualified">
    <xsd:complexType name="PersonType">
        <xsd:sequence>
           <xsd:element name="Name" type="xsd:string"/>
           <xsd:element name="SSN" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Company.xsd

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.company.org"
            xmlns="http://www.company.org"
            elementFormDefault="qualified">
    <xsd:include schemaLocation="Person.xsd"/>
    <xsd:include schemaLocation="Product.xsd"/>
    <xsd:element name="Company">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Person" type="PersonType"
                             maxOccurs="unbounded"/>
                <xsd:element name="Product" type="ProductType"
                             maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

Note that all three schemas have the same targetNamespace:

   http://www.company.org

Also note the mechanism used for accessing components in other schemas which have the same targetNamespace: <include>. When accessing components in a schema with a different namespace the <import> element is used, as we saw above in the Heterogeneous Design.

[3] Chameleon Namespace Design

This design approach says to give the “main” schema a targetNamespace, and the “supporting” schemas have no targetNamespace. In our example, the company schema is the main schema. The person and product schemas are supporting schemas. Below are the three schemas using this design approach:

Product.xsd (no targetNamespace)

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified">
    <xsd:complexType name="ProductType">
        <xsd:sequence>
           <xsd:element name="Type" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Person.xsd (no targetNamespace)

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified">
    <xsd:complexType name="PersonType">
        <xsd:sequence>
           <xsd:element name="Name" type="xsd:string"/>
           <xsd:element name="SSN" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Company.xsd (main schema, uses the no-namespace-schemas)

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.company.org"
            xmlns="http://www.company.org"
            elementFormDefault="qualified">
    <xsd:include schemaLocation="Person.xsd"/>
    <xsd:include schemaLocation="Product.xsd"/>
    <xsd:element name="Company">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="Person" type="PersonType" 
                             maxOccurs="unbounded"/>
                <xsd:element name="Product" type="ProductType"
                             maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

There are two things to note about this design approach:

First, as shown above, a schema is able to access components in schemas that have no targetNamespace, using <include>. In our example, the company schema uses the components in Product.xsd and Person.xsd (and they have no targetNamespace).

Second, note the chameleon-like characteristics of schemas with no targetNamespace:

  • The components in the schemas with no targetNamespace get namespace-coerced. That is, the components “take-on” the targetNamespace of the schema that is doing the <include>
    • For example, ProductType in Products.xsd gets implicitly coerced into the company targetNamespace. This is the reason that the Product element was able to reference ProductType in the default namespace using type=”ProductType”. Ditto for the PersonType in Person.xsd.

“Chameleon effect” … This is a term coined by Henry Thompson to describe the ability of components in a schema with no targetNamespace to take-on the namespace of other schemas. This is powerful!

What is XML and what for its used?

Before going into webservices, we must know what is xml and what for it is used. Hence we will start up with basic xml concepts..

XML stands for eXtensible Markup Language.

XML is designed to transport and store data.

HTML was designed to display data

Main Objective: I hope every1 might got one question in mind like why we need to transfer data thru xml where we can directly transport from frontend language to DB. Eg: say php to mysql

U too doubted on this point right? 😉 Well my seniors explained the good reason and purpose of using XML. According to their theory this is mainly used to transfer data in between two languages(say flash to php) in an simple understand structured data. Henceforth XML come to existence. Even we can use dynamic data to generate in an template manner easily thru XML. Coming to alternatives there are many alternatives to XML in the market but JSON(JavaScript Object Notification) is one of the recent alternative that arrives in the market with good scalability.

What is XML?

  • XML stands for EXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to carry data, not to display data
  • XML tags are not predefined. You must define your own tags
  • XML is designed to be self-descriptive
  • XML is a W3C Recommendation

The Difference Between XML and HTML

XML is not a replacement for HTML.

XML and HTML were designed with different goals:

  • XML was designed to transport and store data, with focus on what data is
  • HTML was designed to display data, with focus on how data looks

HTML is about displaying information, while XML is about carrying information.

XML Does Not DO Anything

Maybe it is a little hard to understand, but XML does not DO anything. XML was created to structure, store, and transport information.

The following example is a note to Tove, from Jani, stored as XML:

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don’t forget me this weekend!</body>
</note>

The note above is quite self descriptive. It has sender and receiver information, it also has a heading and a message body.

But still, this XML document does not DO anything. It is just information wrapped in tags. Someone must write a piece of software to send, receive or display it.

XML Separates Data from HTML

If you need to display dynamic data in your HTML document, it will take a lot of work to edit the HTML each time the data changes.

With XML, data can be stored in separate XML files. This way you can concentrate on using HTML/CSS for display and layout, and be sure that changes in the underlying data will not require any changes to the HTML.

With a few lines of JavaScript code, you can read an external XML file and update the data content of your web page.

XML Simplifies Data Sharing

In the real world, computer systems and databases contain data in incompatible formats.

XML data is stored in plain text format. This provides a software- and hardware-independent way of storing data.

This makes it much easier to create data that can be shared by different applications.

XML Simplifies Data Transport

One of the most time-consuming challenges for developers is to exchange data between incompatible systems over the Internet.

Exchanging data as XML greatly reduces this complexity, since the data can be read by different incompatible applications

XML Documents Form a Tree Structure

XML documents must contain a root element. This element is “the parent” of all other elements.

The elements in an XML document form a document tree. The tree starts at the root and branches to the lowest level of the tree.

All elements can have sub elements (child elements):

<root>
<child>
<subchild>…..</subchild>
</child>
</root>

The terms parent, child, and sibling are used to describe the relationships between elements. Parent elements have children. Children on the same level are called siblings (brothers or sisters).

All elements can have text content and attributes (just like in HTML).

Eg:

<bookstore>
<book category=”COOKING”>
<title lang=”en”>Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category=”CHILDREN”>
<title lang=”en”>Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>

The root element in the example is <bookstore>. All <book> elements in the document are contained within <bookstore>.

The <book> element has 4 children: <title>,< author>, <year>, <price>.

XML Tags are Case Sensitive

XML tags are case sensitive. The tag <Letter> is different from the tag <letter>.

XML Elements Must be Properly Nested

XML Documents Must Have a Root Element

XML Attribute Values Must be Quoted

XML elements can have attributes in name/value pairs just like in HTML.

In XML, the attribute values must always be quoted.

Study the two XML documents below. The first one is incorrect, the second is correct:

<note date=12/11/2007>
<to>Tove</to>
<from>Jani</from>
</note>
<note date=”12/11/2007″>
<to>Tove</to>
<from>Jani</from>
</note>

Comments in XML

The syntax for writing comments in XML is similar to that of HTML.

<!– This is a comment –>

White-space is Preserved in XML

HTML truncates multiple white-space characters to one single white-space:

HTML: Hello           Tove
Output: Hello Tove

With XML, the white-space in a document is not truncated.

XML Attributes Must be Quoted

Attribute values must always be quoted. Either single or double quotes can be used. For a person’s sex, the person element can be written like this:

<person sex=”female”>

or like this:

<person sex=’female’>

If the attribute value itself contains double quotes you can use single quotes, like in this example:

<gangster name=’George “Shotgun” Ziegler’>

XML Elements vs. Attributes

Take a look at these examples:

<person sex=”female”>
<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 an element. Both examples provide the same information.

There are no rules about when to use attributes or when to use elements. Attributes are handy in HTML. In XML my advice is to avoid them. Use elements instead.

Avoid XML Attributes?

Some of the problems with using attributes are:

  • attributes cannot contain multiple values (elements can)
  • attributes cannot contain tree structures (elements can)
  • attributes are not easily expandable (for future changes)

Attributes are difficult to read and maintain. Use elements for data. Use attributes for information that is not relevant to the data.

Don’t end up like this:

<note day=”10″ month=”01″ year=”2008″
to=”Tove” from=”Jani” heading=”Reminder”
body=”Don’t forget me this weekend!”>
</note>
############################################################################

Uniform Resource Identifier (URI)

Uniform Resource Identifier (URI) is a string of characters which identifies an Internet Resource.

The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address. Another, not so common type of URI is the Universal Resource Name (URN).

In our examples we will only use URLs.

Default Namespaces

Defining a default namespace for an element saves us from using prefixes in all the child elements. It has the following syntax:

xmlns=”namespaceURI

This XML carries HTML table information:

<table xmlns=”http://www.w3.org/TR/html4/”&gt;
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>

This XML carries information about a piece of furniture:

<table xmlns=”http://www.w3schools.com/furniture”&gt;
<name>African Coffee Table</name>
<width>80</width>
<length>120</length>
</table>

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&#8221;:

<?xml version=”1.0″ encoding=”UTF-8?><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>
<th style=”text-align:left”>Title</th>
<th style=”text-align:left”>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>

Valid XML Documents

A valid XML document is not the same as a well formed XML document.

The first rule, for a valid XML document, is that it must be well formed (see previous paragraph).

The second rule is that a valid XML document must conform to a document type.

Rules that defines legal elements and attributes for XML documents are often called document definitions, or document schemas.

When to Use a Document Definition?

A document definition is the easiest way to provide a reference to the legal elements and attributes of a document.

A document definition also provides a common reference that many users (developers) can share.

A document definition provides a standardization that makes life easier.

When NOT to Use a Document Definition?

XML does not require a document definition.

When you are experimenting with XML, or when you are working with small XML files, creating document definitions may be a waste of time.

If you develop applications, wait until the specification is stable, before you add a document definition. Otherwise your  software might stop working, because of validation errors

Document Definitions

There are different types of document definitions that can be used with XML:

  • The original Document Type Definition (DTD)
  • The newer, and XML based, XML Schema

XML DTD

An XML document with correct syntax is called “Well Formed”.

An XML document validated against a DTD is “Well Formed” and “Valid”.

Valid XML Documents

A “Valid” XML document is a “Well Formed” XML document, which also conforms to the rules of a DTD:

<?xml version=”1.0″ encoding=”UTF-8?>
<!DOCTYPE note SYSTEM “Note.dtd”>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don’t forget me this weekend!</body>
</note>

The DOCTYPE declaration, in the example above, is a reference to an external DTD file. The content of the file is shown in the paragraph below.

XML DTD

The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements:

<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>

The DTD above is interpreted like this:

  • !DOCTYPE note defines that the root element of the document is note
  • !ELEMENT note defines that the note element contains four elements: “to, from, heading, body”
  • !ELEMENT to defines the to element to be of type “#PCDATA”
  • !ELEMENT from defines the from element to be of type “#PCDATA”
  • !ELEMENT heading defines the heading element to be of type “#PCDATA”
  • !ELEMENT body defines the body element to be of type “#PCDATA”
Note #PCDATA means parse-able text data.

Why Use a DTD?

With a DTD, your XML files can carry a description of its own format.

With a DTD, independent groups of people can agree on a standard for interchanging data.

With a DTD, you can verify that the data you receive from the outside world is valid.

XML Schema

XML Schema is an XML-based alternative to DTD:

In general words its used to validate the XML code..for eg we need to validate some data that is in xml format before we store into our DB. Validation might include syntax, tags, data types etc. Then how you will validate it? Here comes the XML Schema..

<xs:element name=”note”><xs:complexType>
<xs:sequence>
<xs:element name=”to” type=”xs:string”/>
<xs:element name=”from” type=”xs:string”/>
<xs:element name=”heading” type=”xs:string”/>
<xs:element name=”body” type=”xs:string”/>
</xs:sequence>
</xs:complexType></xs:element>

The Schema above is interpreted like this:

  • <xs:element name=”note”> defines the element called “note”
  • <xs:complexType> the “note” element is a complex type
  • <xs:sequence> the complex type is a sequence of elements
  • <xs:element name=”to” type=”xs:string”> the element “to” is of type string (text)
  • <xs:element name=”from” type=”xs:string”> the element “from” is of type string
  • <xs:element name=”heading” type=”xs:string”> the element “heading” is of type string
  • <xs:element name=”body” type=”xs:string”> the element “body” is of type string

Everyting is wrapped in “Well Formed” XML.

XML Schemas are More Powerful than DTD

  • XML Schemas are written in XML
  • XML Schemas are extensible to additions
  • XML Schemas support data types
  • XML Schemas support namespaces

Why Use an XML Schema?

With XML Schema, your XML files can carry a description of its own format.

With XML Schema, independent groups of people can agree on a standard for interchanging data.

With XML Schema, you can verify data.

XML Schemas Support Data Types

One of the greatest strength of XML Schemas is the support for data types:

  • It is easier to describe document content
  • It is easier to define restrictions on data
  • It is easier to validate the correctness of data
  • It is easier to convert data between different data types

Reference: w3schools

How to configure SQLite with php?

Requirements:

The SQLite extension is enabled by default as of PHP 5.0. Beginning with PHP 5.4, the SQLite extension is available only via PECL.

Installation:

Windows users must enable php_sqlite.dll inside of php.ini in order to use these functions.

Windows builds must also enable PDO because as of PHP 5.1.0 it depends on it. So, php.ini will end up with something like this:

extension=php_pdo.dll
extension=php_sqlite.dll

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

SQLITE3_ASSOC (integer)
Specifies that the Sqlite3Result::fetchArray() method shall return an array indexed by column name as returned in the corresponding result set.
SQLITE3_NUM (integer)
Specifies that the Sqlite3Result::fetchArray() method shall return an array indexed by column number as returned in the corresponding result set, starting at column 0.
SQLITE3_BOTH (integer)
Specifies that the Sqlite3Result::fetchArray() method shall return an array indexed by both column name and number as returned in the corresponding result set, starting at column 0.
SQLITE3_INTEGER (integer)
Represents the SQLite3 INTEGER storage class.
SQLITE3_FLOAT (integer)
Represents the SQLite3 REAL (FLOAT) storage class.
SQLITE3_TEXT (integer)
Represents the SQLite3 TEXT storage class.
SQLITE3_BLOB (integer)
Represents the SQLite3 BLOB storage class.
SQLITE3_NULL (integer)
Represents the SQLite3 NULL storage class.
SQLITE3_OPEN_READONLY (integer)
Specifies that the SQLite3 database be opened for reading only.
SQLITE3_OPEN_READWRITE (integer)
Specifies that the SQLite3 database be opened for reading and writing.
SQLITE3_OPEN_CREATE (integer)
Specifies that the SQLite3 database be created if it does not already exist.

The SQLite3 class

A class that interfaces SQLite 3 databases.

SQLite3 {
/* Methods */
public bool busyTimeout ( int $msecs )
public int changes ( void )
public bool close ( void )
public __construct ( string $filename [, int $flags [, string $encryption_key ]] )
public bool createAggregate ( string $name , mixed $step_callback , mixed $final_callback[, int $argument_count = -1 ] )
public bool createCollation ( string $name , callable $callback )
public bool createFunction ( string $name , mixed $callback [, int $argument_count = -1 ] )
public static string escapeString ( string $value )
public bool exec ( string $query )
public int lastErrorCode ( void )
public string lastErrorMsg ( void )
public int lastInsertRowID ( void )
public bool loadExtension ( string $shared_library )
public void open ( string $filename [, int $flags = SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE [, string $encryption_key ]] )
public SQLite3Stmt prepare ( string $query )
public SQLite3Result query ( string $query )
public mixed querySingle ( string $query [, bool $entire_row = false ] )
public static array version ( void )

}

<?php

$db = new SQLite3(‘:memory:’);

$db->createCollation(‘translit_ascii’, function ($a, $b) {
$a = transliterator_transliterate(‘Any-Latin; Latin-ASCII; Lower()’, $a);
$b = transliterator_transliterate(‘Any-Latin; Latin-ASCII; Lower()’, $b);
return strcmp($a, $b);
});

$db->exec(‘
CREATE TABLE people (name COLLATE translit_ascii);
INSERT INTO people VALUES (“Émilie”);
INSERT INTO people VALUES (“Zebra”);
INSERT INTO people VALUES (“Emile”);
INSERT INTO people VALUES (“Arthur”);
‘);

$stmt = $db->prepare(‘SELECT name FROM people ORDER BY name;’);
$result = $stmt->execute();

while ($row = $result->fetchArray())
{
echo $row[‘name’] . PHP_EOL;
}

// Displays:
// Arthur
// Emile
// Émilie
// Zebra

?>

The SQLite3Stmt class

A class that handles prepared statements for the SQLite 3 extension.

SQLite3Stmt {
/* Methods */
public bool bindParam ( string $sql_param , mixed &$param [, int $type ] )
public bool bindValue ( string $sql_param , mixed $value [, int $type ] )
public bool clear ( void )
public bool close ( void )
public SQLite3Result execute ( void )
public int paramCount ( void )
public bool reset ( void )

}

This method can be used like this :

<?php

$db = new SQLite3(‘:memory:’);
$db->exec(‘CREATE TABLE test (column);’);

$stmt  = $db->prepare(‘SELECT column FROM test;’);
var_dump($stmt->readOnly()); // -> true

$stmt  = $db->prepare(‘INSERT INTO test (42);’);
var_dump($stmt->readOnly()); // -> false

?>

You can even execute your sql commands online here

SQLite – Useful Functions

SQLite has many built-in functions for performing processing on string or numeric data. Following is the list of few useful SQLite built-in functions and all are case in-sensitive which means you can use these functions either in lower-case form or in upper-case or in mixed form. For more details, you can check official documentation for SQLite:

S.N. Function & Description
1 SQLite COUNT Function
The SQLite COUNT aggregate function is used to count the number of rows in a database table.
2 SQLite MAX Function 
The SQLite MAX aggregate function allows us to select the highest (maximum) value for a certain column.
3 SQLite MIN Function
The SQLite MIN aggregate function allows us to select the lowest (minimum) value for a certain column.
4 SQLite AVG Function 
The SQLite AVG aggregate function selects the average value for certain table column.
5 SQLite SUM Function
The SQLite SUM aggregate function allows selecting the total for a numeric column.
6 SQLite RANDOM Function
The SQLite RANDOM function returns a pseudo-random integer between -9223372036854775808 and +9223372036854775807.
7 SQLite ABS Function
The SQLite ABS function returns the absolute value of the numeric argument.
8 SQLite UPPER Function
The SQLite UPPER function converts a string into upper-case letters.
9 SQLite LOWER Function
The SQLite LOWER function converts a string into lower-case letters.
10 SQLite LENGTH Function
The SQLite LENGTH function returns the length of a string.
11 SQLite sqlite_version Function
The SQLite sqlite_version function returns the version of the SQLite library.

You can download pdf file from here

References:

http://sqlite.org/

http://in1.php.net/sqlite3

http://zetcode.com/db/sqlite/

http://www.tutorialspoint.com/sqlite/

What is SQLite and when to use it??

What is SQLite?

To define in an simple manner, SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

SQLite is a relational database management system contained in a C programming library. In contrast to other database management systems, SQLite is not a separate process that is accessed from the client application, but an integral part of it.

SQLite is a popular choice as embedded database for local/client storage in application software such as web browsers. It is arguably the most widely deployed database engine, as it is used today by several widespread browsers, operating systems, and embedded systems, among others. SQLite has many bindings to programming languages.

Unlike client–server database management systems, the SQLite engine has no standalone processes with which the application program communicates. Instead, the SQLite library is linked in and thus becomes an integral part of the application program. The library can also be called dynamically. The application program uses SQLite’s functionality through simple function calls, which reduce latency in database access: function calls within a single process are more efficient than inter-process communication. SQLite stores the entire database (definitions, tables, indices, and the data itself) as a single cross-platform file on a host machine. It implements this simple design by locking the entire database file during writing. SQLite read operations can be multitasked, though writes can only be performed sequentially.

In the simplest terms, SQLite is a public-domain software package that provides a relational database management system, or RDBMS. Relational database systems are used to store user-defined records in large tables. In addition to data storage and management, a database engine can process complex query commands that combine data from multiple tables to generate reports and data summaries. Other popular RDBMS products include Oracle Database, IBM’s DB2, and Microsoft’s SQL Server on the commercial side, with MySQL and PostgreSQL being popular open source products.

The “Lite” in SQLite does not refer to its capabilities. Rather, SQLite is lightweight when it comes to setup complexity, administrative overhead, and resource usage. SQLite is defined by the following features:

Serverless
SQLite does not require a separate server process or system to operate. The SQLite library accesses its storage files directly.

Zero Configuration
No server means no setup. Creating an SQLite database instance is as easy as opening a file.

Cross-Platform
The entire database instance resides in a single cross-platform file, requiring no administration.

Self-Contained
A single library contains the entire database system, which integrates directly into a host application.

Small Runtime Footprint
The default build is less than a megabyte of code and requires only a few megabytes of memory. With some adjustments, both the library size and memory use can be significantly reduced.

Transactional
SQLite transactions are fully ACID-compliant, allowing safe access from multiple processes or threads.

Full-Featured
SQLite supports most of the query language features found in the SQL92 (SQL2) standard.

Highly Reliable
The SQLite development team takes code testing and verification very seriously.

Overall, SQLite provides a very functional and flexible relational database environment that consumes minimal resources and creates minimal hassle for developers and users.

Misconceptions

Don’t be deceived into thinking that Sqlite is only for testing and development. For example, it works fine for websites receiving up to 100,000 hits a day– and this is a conservative limit. The maximum size for a Sqlite database is 140 Terabytes (which should be enough, right?), and it can be substantially faster than a full-blown RDBMS. The full database and all other necessary data is stored in a normal file in the host’s file system, so no separate server process is needed (cutting out all need for slow inter-process communication).

Best example:

It’s good for situations where you don’t have access to a “real” database and still want the power of a relational db. For example, Firefox stores a bunch of information about your settings/history/etc in an SQLite database. You can’t expect everyone that runs firefox to have MySQL or postgre installed on their machine.

How to create a simple chrome extension

Guys,

Today we will see how to create your own simple “Hello world” extension.

It’s pretty simple to develop a simple extension..

Worried how? All you need is just basic knowledge on Javascript and HTML. Before going deep into development of extension let me brief on different types of extensions.

Types of extensions:

Basically there are 4 types of extensions..

1.Browser Actions: add an icon next to your address bar (i.e. to show a popup)

2.Page Actions: show a little icon in the address bar

3.Desktop notifications: show notifications on your desktop

4.Omnibox: add functionality to your address bar with predefined keywords

In this tutorial i will focus more on browser action..

Let’s Start..

To build your own chrome extension, first create a folder in your local drive with some name..

In my example I named it as “Hello World”

In this folder, we need to hold mainly

  1. Manifest.json
  2. Popup.html
  3. Youricon.png
  4. some.js

I hope you are aware of manifest.json file from our previous post. Still i will do explain..

Manifest file

The manifest file contains all the information Chrome needs to understand how your extension should work.

Copy the below code to manifest.json file..

{

 “name”: “test extension”,

 “description”: “testing popup with hello world message”,

 “version”: “1”,

 “manifest_version”: 2,

 “permissions”: [“tabs”, “http://*/*&#8221;, “background”],

 “content_scripts”: [{“matches”: [“http://*/*”%5D,”js&#8221;: [“some.js”]}],

 “browser_action”: {“default_icon”: “16×16.png”,”default_popup”: “popup.html”}

}

Now save this file as “manifest.json” in your extension folder(here Hello World).

Note: notice every rule is ended with a comma except the last one.

Now let me go through the fields in manifest.json file. You can have a look of full field summary here

#  permissions: You need to set permissions if you want to use some of the API functionality of Chrome extensions.

  • tabs: if you want to access tabs or detect when something changes in a tab.
  • url: determine which webpages you want your extension to work with (use http://*/* for all websites).
  • background: if you want to use a background page (clarified further down this page).

#  background_page: specify the file that will serve as your background page.(this had been removed in latest version chromes..so this wont support now). For your understanding I still mentioned here..

# content_scripts

  • matches: specify for which webpages the content script should be injected.
  • js: specify the file that will serve as your content script.

#  browser_action

  • default_icon: specify where the icon for your extension is located (must be 16px wide and 16px high) in your extension folder.
  • popup: specify the file that will serve as your popup page.

Popup.html

Most Chrome extensions use a popup window that shows up if you click on an extension icon. This popup browser action, as Google likes to call it, is particularly useful if you want to show information to your users without interrupting the browsing experience.

To show “Hello World!” to your users, create a new file called “popup.html” and add the following lines of code.

<html>  <head><title>Hello World!</title></head>

  <body>

    <p>Hello World!</p>

  </body>

</html>

But since we also specified other files in our manifest file we must add those files to the folder as well. So before you can fire up your extension, create the next dummy files, which we’ll be needed to run this extension for now.

some.js: create an empty Javascript file

Youricon.png: you need a 16 by 16px icon

How to install your chrome extensions?

In your browser’s address bar, just type in:

1 chrome://extensions

Make sure that you check Developer mode and click the Load unpacked extension… button. Then simply select the folder from your hard disk which contains the extension’s files.

extensionspanel

Your extension should now be loaded in your Chrome browser. To confirm if everything went well, check if a new icon appeared next to the address bar like the following image.

14-03-2014 18-03-57

You even can download my example here

I hope its clear now.. Stay tuned to Sathyalog 😀