XML

XML without whitespaces not human readable

To save storage and network bandwidth, XML documents are sometimes provided without whitespaces. This makes it hard for an average user to read and understand the content of the document. A tool to add this whitespaces again and pretty print the document would be helpful. Also it would be nice to be able to collapse certain hierarchy levels, to focus on the areas you want to read.

Taggings:

Use Notepad++ to view and edit XML documents

Notepad++ is a free source code editor and Notepad replacement that supports several formats. In its basic edition it can already do some nice things like:

  • collapse structured texts like XML on a certain hierarchy level with the key combination "Alt"+X, where X is a number between 1 and 8. Uncollapse with "Shift"+"Alt"+X.
  • Extended search and replace with e.g. line breaks or search and replace using regular expressions.
  • Vertical selection and simultaneous editing of text holding down the "Alt" key.
  • and many more...
  • If you download the XML Tools Plugin you can also pretty print XML documents without witespaces. Just select it from the plugins menu or use the keyboard shortcut "Ctrl"+"Alt"+"Shift"+"B". Check out also the other features provided with the plugin.

    Taggings:

    How to join entries of a repeated table in one text field in InfoPath

    1. We have to define the repeated tables that have to be join
    2. We have to define the fields in the repeated table
    3. We have to define help fields (here is the text of the join of the repeated tabele)

    This method will join two differnt repeated table in two different text fields. to understand the method how it works.


    public void zusammenfassung_wtabs_anfang()
    {
    try
    {
    XPathNodeIterator itemnodes;
    string[] wtabs = {
    "/my:XPath_to_repeated_tabel_1",
    "/my:XPath_to_repeated_tabel_2",
    };
    string[] fields = {
    "my:field_1_of_repeated_table_1~my:fiedl_2_of_repeated_1",
    "my:field_1_of_repeated_table_2~my:fiedl_2_of_repeated_2",
    };
    string[] zielfelder = {
    "/XPath_to_help_field_repeated_table_1/my:help_1",
    "/XPath_to_help_field_repeated_table_2/my:help_2"
    };
    string[] satzende = {
    ".",
    "."
    };
    for (int i = 0; i < wtabs.Length; i++)
    {
    string endtext = "";
    itemnodes = this.MainDataSource.CreateNavigator().Select(wtabs[i], NamespaceManager);
    foreach (XPathNavigator itemNode in itemnodes)
    {
    for (int j = 0; j < fields[i].Split('~').Length; j++)
    {
    endtext += itemNode.SelectSingleNode(fields[i].Split('~')[j], NamespaceManager).Value + " ";
    }
    endtext = endtext.Substring(0, endtext.Length - 1);
    endtext += ", ";
    }
    try
    {
    endtext = endtext.Substring(0, endtext.Length - 2);
    }
    catch (Exception ex)
    { }
    if (endtext.Trim().Length < 2)
    endtext = "";
    else
    endtext = endtext + satzende[i].ToString();
    this.MainDataSource.CreateNavigator().SelectSingleNode(zielfelder[i], this.NamespaceManager).SetValue(endtext);
    endtext = "";
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show("Test" + ex.Message);
    }
    }

    Taggings:

    How to reset font size formatting in XML/InfoPath file with c#

    Currently i am developing an medical software. Therefor i use InfoPath form template with code behind c# and MS SQL or Infomix databse was a very comfortable solution. As the complexety of the system grows i had to broaden my horizon and find some tricky solutions to achieve the surreal requirements of the client. If users change the standard size formation of an richtext field and you wish to reset the font size back to the standard formatation this method will help you. People always want everyhing flexibel, fast and automatically,... properties which are very hard to reach within a software. So someday i encountered a very hard problem which took me a long time to solve it (although, afterwards it wasn't so difficult). If someone has programmed a little bit with c# before and knows about XML formating, its not that hard to rest the font size of richtext fields. So a solution had to be found. After hours of internet surfing and testing many methods i found the best way to solve this problem.

    Display a local public transport route by using the Wiener Linien API

    The core problem of this challenge is the proper formulation (encoding) of the request and the correct interpretation (decoding) of the server-response. Another problem is the sending and the receiving of the XML-files with a server-side scripting language such as PHP.

    programming with OWL API

    -What is OWLAPI -Why we need OWL API -How can we use OWP API -Example

    Prototype Autocomplete

    Prototype is a JavaScript framework that makes web development a lot easier.
    You can download it at www.prototypejs.org

    You can use prototype to create an AutoComplete input box:

    At first you'll need to include prototype into your website:

    <script type="text/javascript" src="prototype.js"></script>
    <script type="text/javascript" src="autocomplete.js"></script>

    Now create an input box

    <input type="text" name="q" id="query" />

    and an instance of your Autocomplete object:

    <script type="text/javascript">
    new Autocomplete('query', { serviceUrl:'service/autocomplete.ashx' });
    </script>

    If you want, you can add further options:

    new Autocomplete('query', {
    serviceUrl:'service/autocomplete.ashx',
    minChars:5,
    maxHeight:350,
    width:400,
    deferRequestBy:100,
    // callback function:
    onSelect: function(value, data){
    alert('You selected: ' + value + ', ' + data);
    }
    });

    autocomplete.ashx will receive the GET request with the querystring ?query=Know - it must return JSON data as follows:

    {
    query:'Know',
    suggestions:['Knowledge Management','Knowing','Know How'],
    data:['KM','KN','KH']
    }

    Using Java to read an XML file

    The DOM is a W3C (World Wide Web Consortium) standard. The DOM defines a standard for accessing documents like XML and HTML:"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document." </br> The DOM is separated into 3 different parts / levels: </br> Core DOM - standard model for any structured document </br> XML DOM - standard model for XML documents </br> HTML DOM - standard model for HTML documents </br> The DOM defines the objects and properties of all document elements, and the methods (interface) to access them. Write a program to read the content of an XML file using DOM parser.

    Navigation, Predicates and Functions in XPath

    <strong>Write the following XPath queries for the document finance.xml: </strong> • head of all articles between the 4th and the 9th of May • The first and the third article of Alliance & Leicester • The depth of the XML document (Hint: XPath2 usage) • Explain why the query //head[2] returns a different result to descendant::head[2], and how the results look like for this particular example file </br> <p> </strong>Get the maximum and minimum of the values in values.xml </strong> • Try first to do it in XPath1 (trick: use negation of existential comparison) • Write an XPath2 query that iterates over the numbers 1 to 12 and returns the square product of each number • Return the concatenated textual value of all the child elements of the element data in text.xml. Further, remove all non-breakable spaces that are used in the concatenated text. And normalize/trim the white-spaces finally . </p> The files <cite>finance,values</cite> can be found in the attachment.

    Make the Navigation Menu user specific

    For a workflow application serveral user types are defined. In general, depending on their roles, users have different rights. In particular the navigation menu must be user specific (e.g. some users may have write access, others only read access ).

    Pages

    Subscribe to XML