Archive for the Category XML

 
 

Editing Xml Schema

Xml schema is used when xml based communication is needed between different systems, the xml schema is used to describe the structure of an xml document.  In this tutorial, I will demonstrate how to edit an xml schema using Liquid XML Studio.
Working with Liquid XML Studio is very straightforward because of its design view feature which is user friendly, and very easy to use.
For this I am using Simple Book Store Project which has some default values, the output looks like this:

img1

The Schema Looks Like this :

img2

Now if Another Column is to be added (Distributor), you need to change the xml schema to make your xml document valid. Using Liquid Xml Studio, we can open the schema document, in the design view of the xml schema you can see the structure of xml document there you can do your changes by editing the nodes . To add another node you, follow below steps.

  • Right Click on the Schema Root
  • Select Add Child
  • Child Type is Complex Type in the Design view part of Liquid Xml Studio

img3

Name it as Distributor.

Distributor can have several attributes as distributor name, distributor city etc.

Let’s create few of them.

Let’s say the full name is coming from 2 different columns in the database so you can combine them in one node by using sequence which will concat the values and display it one string. Sequence can be used for other data types also.

To create a sequence you can use same procedure .Right Click on the node on which you need to create child sequence and under “Add Child” select sequence.

Now add child elements to the sequence like Distributor Name, Distributor Organization Name

After adding few fields it looks like this:

img5

Lets make Some changes in XSLT file so that it can be shown in the html page.

img6

And Html Page with some dummy values look like this:

img7

So by doing all the changes in xml schema we get this output:

img8

So by using Liquid XML Studio you can edit the XML schema and change the structure of the XML Document used in any communications.

XMLQuire – a free light XML Editor

 

This XML Editor is the result of a rethink on one of the very fundamental principles of the way we edit XML text, namely XML formatting.In this editor, no tab or space characters are used for XML indentation. Instead, the left-margin adjusts continuously to ensure the XML always appears properly formatted. The editing experience is quite different from normal, because as you edit XML, you will find that the XML reflows into new formatting patterns continuously, even
when the XML structure is altered significantly, there’s no ‘reformat’ button to press.

Features

  • Support for Windows XP or later
  • Syntax-highlighting and auto-completion
  • Schema validation and schema-aware completion lists
  • XPath Editor with auto-completion and full predicate/function tracing
  • DTD caching
  • Regex powered Find and Replace with preview
  • Special Print Preview with XML print formatting options
  • Recent Files list with preserved state replaces document tabs
  • Left-justified alternative view option
  • Multi-process and Multi-monitor editing windows
  • Smart trimming of formatted XML for import compatibility with existing editors
  • Synchronized element outline tree and sibling node value list

web-screen XMLQuire can be downloaded from http://xmlquire.com

How to fix delicious add-on for Firefox 4

Firefox 4 excellent and very fast browser, but many add-ons stopped working. One of them is delicious add-on. Of course is possible to use delicious bookmarklets, but it certainly can not replace all functionality that old delicious add-on has. With the help of a small change in one of the files – it will be possible to return the add-on back to the “life”.

First thing to do, in the windows explorer enter the following path:

%appdata%\Mozilla\Firefox\Profiles

Choose a folder that name ends with .default extension.Then go to extensions folder.

In the folder locate a directory with following GUID (represents delicious add-on)

{2fa4ed95-0317-4c6a-a74c-5f3e3912c1f9}

Under GUID directory open install.rdf file in any text editor.

Find a line contains  em:maxVersion attribute .

Change attribute value to “4.0”.Save the file . Restart Firefox 4 .

Final file shown below

<?xml version="1.0"?>

  
  
    
  

XPath Visualizer

 

XPath Visualizer is a simple tool, that lets you execute a XPath query and see the results. The .Net 3.5 is required to use the tool .

XPathVisualizer-v1.2

Features:

  • Load the XML document from a filesystem file, from an HTTP URL, type it in, or paste (Ctrl-V).
  • Automatically detect and display the XML namespaces in use, in the document, including those with and without explicit prefixes
  • XPath query validation.
  • Remembers 10 most-recently used XPath queries.
  • automatically inject the default xml namespace into query expressions
  • visualize the XPath query execution results on the XML document
  • Easy scroll through the matched nodes of an XPath query
  • strip XML namespaces from any document
  • Remove matched nodes in the document
  • Reindent or reformat XML
  • After modifying the XML in any way, you can save the modified XML document to a new file

Download XPath Visualizer (Codeplex)

Return the value for the specific attribute using XPathNodeIterator

I will use the following XML document in the example below.

<?xml version="1.0" encoding="utf-8" ?>
<users>
  <user FirstName="Tom" LastName="Adams" Age="23" />
  <user FirstName="Jhon" LastName="Brams" Age="17" />
  <user FirstName="Bill" LastName="Smith" Age="33" />
</users>

The code prints out all the user nodes of the users node that  have an age with a value greater than 17.

// Read the xml from resource file 
string xml = Resources.Users; 
using (StringReader sr = new StringReader(xml)) 
{ 
    XPathDocument document = new XPathDocument(sr); 
    XPathNavigator navigator = document.CreateNavigator(); 
    XmlNamespaceManager ns = new XmlNamespaceManager(navigator.NameTable); 
    //Selects all the user nodes of the users node that 
    // have an age with a value greater than 17  
    XPathNodeIterator it = navigator.Select("/users/user[@Age>17]"); 
    while (it.MoveNext()) 
    { 
        // access the atributes  
        string firstName = it.Current.GetAttribute("FirstName", ns.DefaultNamespace); 
        string lastName = it.Current.GetAttribute("LastName", ns.DefaultNamespace); 
        // Print out  
        Console.WriteLine( "{0} {1}", firstName, lastName ); 
    } 
}


Page 1 of 212