JavaScript xsd validation and examples

<SCRIPT LANGUAGE=”JavaScript”>
var sOutput = validateFile(“sc-valid.xml”);
alert(sOutput);

function validateFile(strFile)
{
// Create a schema cache and add books.xsd to it.
var xs = new ActiveXObject(“MSXML2.XMLSchemaCache.4.0”);
xs.add(“urn:books”, “sc.xsd”);

// Create an XML DOMDocument object.
var xd = new ActiveXObject(“MSXML2.DOMDocument.4.0”);

// Assign the schema cache to the DOMDocument’s
// schemas collection.
xd.schemas = xs;

// Load books.xml as the DOM document.
xd.async = false;
xd.validateOnParse = true;
xd.resolveExternals = true;
xd.load(strFile);

// Return validation results in message to the user.
if (xd.parseError.errorCode != 0)
{
return(“Validation failed on ” + strFile +
“n=====================” +
“nReason: ” + xd.parseError.reason +
“nSource: ” + xd.parseError.srcText +
“nLine: ” + xd.parseError.line + “n”);
}
else
return(“Validation succeeded for ” + strFile +
“n======================n” +
xd.xml + “n”);
}

</SCRIPT>
=========================

File: sc-valid.xml
——————-
<?xml version=”1.0″?>
<x:catalog xmlns:x=”urn:books”>
<book id=”bk101″>
<author>Gambardella, Matthew</author>
<title>XML Developer’s Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
</x:catalog>

—————————–
File: sc.xsd
—————————–
<xsd:schema xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
targetNamespace=”urn:books”
xmlns:b=”urn:books”>
<xsd:element name=”catalog” type=”b:CatalogData”/>
<xsd:complexType name=”CatalogData”>
<xsd:sequence>
<xsd:element name=”book”
type=”b:bookdata”
minOccurs=”0″
maxOccurs=”unbounded”/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name=”bookdata”>
<xsd:sequence>
<xsd:element name=”author” type=”xsd:string”/>
<xsd:element name=”title” type=”xsd:string”/>
<xsd:element name=”genre” type=”xsd:string”/>
<xsd:element name=”price” type=”xsd:float”/>
<xsd:element name=”publish_date” type=”xsd:date”/>
<xsd:element name=”description” type=”xsd:string”/>
</xsd:sequence>
<xsd:attribute name=”id” type=”xsd:string”/>
</xsd:complexType>
</xsd:schema>

Post Your site to search engines

How to Post Your site to search engines

Click on the below links and post your site to top most search engines

  1. http://www.google.com/addurl/
  2. http://submit.search.yahoo.com/free/request/
  3. http://search.msn.com/docs/submit.aspx
  4. https://adwords.google.com/select/
  5. http://static.wc.ask.com/en/docs/about/webmasters.shtml#18
  6. http://www.gigablast.com/addurl

Search Engine Statistics – What Market Share?

2008 April: According to 2008 March figures from Hitwise

  1. Google has the largest market share of U.S. based web searches at 67%
    • 2008 February 66.44%
    • 2008 January 65.98%
    • 2007 December 65.98%
    • 2007 November 65.10%
    • 2007 October 64.49%
    • 2007 September 63.55%
    • 2006 October 60.94%
  2. Yahoo is second with a market share of 20%
    • 2008 February 20.59%
    • 2008 January 20.94%
    • 2007 December 20.88%
    • 2007 November 21.21%
    • 2007 October 21.65%
    • 2007 September 22.55%
    • 2006 October 22.34%
  3. MSN is third with a market share of 7%
    • 2008 February 6.95%
    • 2008 January 6.90%
    • 2007 December 7.04%
    • 2007 November 7.09%
    • 2007 October 7.42%
    • 2007 September 7.83%
    • 2006 October 10.72%
  4. Ask is fourth with a market share of 4%
    • 2008 February 4.16%
    • 2008 January 4.21%
    • 2007 December 4.14%
    • 2007 November 4.63%
    • 2007 October 4.76%
    • 2007 September 4.32%
    • 2006 October 4.34%

Source: Hitwise Press Releases

Web Site Designing and publishing

Free Hit Counters

  1. http://my.statcounter.com
  2. http://easyhitcounters.com
  3. http://www.statssheet.com
  4. http://www.neoworx.net

Free Maps on Your Site

  1. http://clustrmaps.com
  2. http://www.ip2map.com
  3. http://www.neoworx.net

Free Site Stats Reports

  1. http://my.statcounter.com/
  2. http://www.statssheet.com

Track the location of visitor

  1. http://www.ip2phrase.com/
  2. http://my.statcounter.com/
  3. http://www.neoworx.net/

Web Master Tools

  1. https://www.google.com/webmasters

Live Cricket On your Site

  1. http://www.vcricket.com

Free Web Site Hosting

  1. www.blogspot.com
  2. www.googlepages.com
  3. www.50megs.com
  4. www.geocities.com
  5. www.netfirms.com

PHP – Ubuntu 9.04 + PHP5 + GD2

It all started when I decided to optimize image slicing algorithm for a new feature on UMapper – and since GD is quite RAM-intensive, I needed to check actual memory consumption, and the obvious choice to do so was PHP’s memory_get_usage() function. However, it failed to produce accurate results – it seemed like images loaded into memory weren’t accounted by the function (RAM was still used :) ).
As it turned out, whoever prepared official php5-gd package, compiles against original GD, and not using PHP5 bundled version of the library. I actually wasn’t aware about the fork, but here is explanation from GD Official Site:

The PHP version of gd offers features similar to and sometimes in addition to those included in the latest version of gd found here as well as many bug fixes not present in the latest GD release. If you are working with PHP, using the built-in gd of PHP 4.3.0 or better is recommended.

We are working to merge the changes done in the PHP GD in the normal GD library.

Well, I was pretty sure that unexpected behavior was caused by using original GD library instead of bundled one. So I decided to remove php5-gd package, recompile php5 from sources, and install updated GD package – which is exactly what gets bundled with PHP5 on other distributions.

Google is my friend, so here is a walkthrough:

# Install build tools, debian helpers and fakeroot
apt-get install build-essential debhelper fakeroot
# Get PHP source (it should go into /usr/src)
cd /usr/src
apt-get source php5
# Install all packages required to build PHP5
apt-get build-dep php5

#Now what we need is to update compile options,
# so we need to edit debian/rules file:
cd php5-5.2.6.dfsg.1
vim debian/rules
# locate the line having “–with-gd=shared,/usr –enable-gd-native-ttf \”
# replace with “–with-gd=shared –enable-gd-native-ttf \”
# that’s remove reference to /usr so that bundled library is used

# compile (drink some coffee, walk you dog, see the latest House episode)
dpkg-buildpackage -rfakeroot

# install the new php5-gd package
cd ..
dpkg -i php5-gd_5.2.6.dfsg.1-3ubuntu4.2_i386.deb

# finally restart apache
/etc/init.d/apache2 restart

That’s it – you should be able to see «bundled» near the GD version in the phpinfo() output. Well, that’s not the only gain – it solves problem with memory_get_usage() as well :)

Now, once I had memory_get_usage() working correctly, back to optimization..