# Saturday, April 23, 2016


Some time you may need to wrap text node in a CDATA section as part of your XQuery development. For example say you need to generate the following document


<?xml version="1.0" encoding="UTF-8"?>
<sf:Resource xmlns:sf="http://www.canadapost.ca/smartflow" contentID="PAYMENT">
<![CDATA[
        <payment-data>
           <account-number>bar</account-number>
            <total-due>bar</total-due>             <due-date>bar</due-date>         </payment-data> ]]></sf:Resource>

The following query makes use of a processor specific XQuery option called ddtek:serialize 

Notice the syntax to define an expanded QName with namespace is { {uri} local-name }  which is different from what is erroneously described in the XQuery Tips & Tricks 

The second takeaway is how the content inside sf:Resource needs to be escaped text to produce the required result

declare namespace sf="http://www.canadapost.ca/smartflow";
declare option ddtek:serialize "omit-xml-declaration=no,encoding=UTF-8,indent=yes,cdata-section-elements={{http://www.canadapost.ca/smartflow}Resource}";
declare variable $foo := "bar";
<sf:Resource contentID="PAYMENT">
   &lt;payment-data&gt;
       &lt;account-number&gt;{ $foo }&lt;/account-number&gt;
       &lt;total-due&gt;{ $foo }&lt;/total-due&gt;
       &lt;due-date&gt;{ $foo }&lt;/due-date&gt;
   &lt;/payment-data&gt;
</sf:Resource>


Multiple CDATA sections are declared using ; as separator


cdata-section-elements="{{http://www.canadapost.ca/smartflow}Resource};{{http://www.canadapost.ca/smartflow}Foo}"




posted on Saturday, April 23, 2016 5:58:32 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Monday, May 13, 2013
Stylus Scoop - From Stylus Studio
May 2013 - Keep Your Library Up-to-Date with Google Books API

Hello from the Stylus Studio Team!

Summertime is just about here. The Stylus Studio team hopes everyone is having a great year so far. We are working on some new & exciting technologies and can not wait to share them with you.

In the meantime, we hope you read and enjoy this month's tutorial entitled "Keep Your Library Up-to-Date with Google Books API". This tutorial looks at retrieving up-to-date book information using technologies like XQuery, JSON and Web Service with just one single tool, the Stylus Studio XML IDE.

Join Our New LinkedIn Group - Check Out Our New LinkedIn Group and Discuss Stylus Studio, XML and More with other Stylus Studio Users and XML Professionals

 
Keep Your Library Up-to-Date with Google Books API

Books are fundamental elements of our culture. No matter where you live or what your cultural background, I am sure that there has been at least one book that impacted your life and left great memories.

Stylus Studio

Because the content of books is so important to humankind in many ways, we invest significant amounts of time and money to help them stand the test of time, and of course, we organize them so we can quickly find a particular title or author when needed.

Read the Full Article >
Using XQuery To Generate JSON from Relational Data

This article describes how to build a simple multi-tier solution to expose relational data to a modern HTML application using JSON.

Read the Full Article >
Maintenance Release 1910i Now Available

Get the details on the latest maintenance release of Stylus Studio X15.

Release Details >
posted on Monday, May 13, 2013 10:53:26 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback
# Wednesday, February 20, 2013

Hello from the Stylus Studio Team!

We hope everyone is having a great 2013 so far. With the start of a new year, the Stylus Studio team is looking at new and amazing ways to enhance Stylus Studio and offer the best XML Editor and Development Environment possible.

This month we have a tutorial entitled "Using XQuery To Generate JSON from Relational Data". We hope you enjoy this tutorial and if you have any ideas on tutorials or articles you want to see in upcoming Stylus Scoops, please let us know.

If you like the Sylus Scoop help us get the word out! Click the "+1" button on the top of our website (next to the logo) to +1 us with your Google+ account.

Using XQuery To Generate JSON from Relational Data

This article describes how to build a simple multi-tier solution to expose relational data to a modern HTML application using JSON.

Stylus Studio Using XQuery

We want to expose the database through a simple REST web service interface which allows a variety of client technologies to query the data without being tightly coupled to the underlying database product.

Read the Full Article >
Maintenance Release 1910g Now Available

Get the details on the latest maintenance release of Stylus Studio.

Release Details >
X15 Is Now Available

The latest and greatest release of Stylus Studio is now available. Stylus Studio X15 Enterprise Suite's awesome new features include:

  • New HTML WYSIWYG Editor Tab
  • Real-Time HTML Editing, Results and Preview
  • Overhaul and Enhancements to Sense X - Intelligent XML Editing
  • One Click Intelligent AutoLink for XSLT and XQuery Mapping Tools

See the New Features Now >
NEW VIDEO - Quick Tour Video

Check out our latest video to get a quick overview of the Stylus Studio suite.

Watch the Video Now >
posted on Wednesday, February 20, 2013 9:05:53 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Monday, November 19, 2012

November 2012 - Learn XQuery in 10 Minutes

Hello from the Stylus Studio Team!

With the W3C XQuery working group gearing up to XQuery 3.0 and a variety of new XQuery products coming to market, we are seeing a growing interest in learning the language fundamentals and use cases, therefore this month we want to propose one of the finest introductory articles on the topic, written by Dr. Michael Kay, the editor of the W3C specification of the XSLT 2.0 language and author of best seller ‘XSLT 2.0 and XPath 2.0 Programmer's Reference'.


Cyber Monday is coming! Stay tuned to the Stylus Studio Facebook Page and Twitter Account to find out how Stylus Studio will make your Cyber Monday amazing.
 

If you like the Sylus Scoop help us get the word out! Click the "+1" button on the top of our website (next to the logo) to +1 us with your Google+ account.

Learn XQuery in 10 Minutes

By: Dr. Michael Kay

This XQuery tutorial is for all those people who really want to know what XQuery is, but don't have the time to find out. We all know the problem: so many new technologies, so little time to research them. To be honest, I hope that you'll take more than ten minutes on this XQuery tutorial — but if you really have to leave that soon, I hope you'll learn something useful anyway.

Processing Historical Data

Read the Full Tutorial >
Check Out the New Stylus Studio XML Editor Blog

The Stylus Studio team is happy to present the brand new XML Editor Blog. Visit often or subscribe via RSS to get the latest Stylus news, XML news, XML tutorials and more.

Got a suggestion for a blog entry or tutorial? We would love to hear it. Email us at stylusstudio@ivitechnologies.com with your suggestion.

Visit the Blog >
Stylus Studio Maintenance Release - Build 1893g

The Stylus Studio team has announced the release of Stylus Studio® X14 Release 2 Build 1893g. This latest maintenance release included bug fixes to handle known, user-reported issues.

See the Release Notes >
posted on Monday, November 19, 2012 1:48:38 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] Trackback
# Tuesday, September 18, 2012

Presidential Elections, Processing Historical Data

We are approaching a new presidential election here in the US, and many are very excited to follow the evolving political trends.   The election results are very important public records which allow anyone to verify the transparency of the core process for any modern democracy.

In this article we explore how to extract election historical data, stored in a variety of data sources and use Stylus Studio in a creative manner.

We start with the 2004 election result which we have found in the text format. In the following screenshot, we see the raw flat file.

 

 

We can now convert the data using the Convert to XML module which allows us to generate an XML document with a few clicks. We use the first line in the file to create the element names.  The preview window shows the conversion result.

 

Once the data  is converted to XML we can open the document using the Stylus Studio XML editor; switching  to the Grid view allows us to easily sort the grid content using any of the column headers (right click-> Sort)

 

Now that we have full control on the data for the 2004 election results, we can move to the 2008 election. This data has been stored in a relation database; the simple diagram below illustrates the relationship between the “States” table and the “Election2008” table.

 

Our goal is to query the database and to generate an XML document which will have a similar structure to the previously converted flat file. For this task we are going to use the DataDirect XQuery engine which allows for joining the table’s data and returning an XML document.

In the following screenshot you can see how the XQuery mapping tool has been used to build a “for” statement and the collection function calls are used to access the database tables. The equal operator matches the records where the StateID is the same.

The preview window which captures the query result has been undocked to reduce the real-estate.

 

 

If you are wondering how such an approach can scale with a large database, take a peek at the query plan to discover what happens under the cover. The following screenshot reveals that the query has been translated into a SQL SELECT and it runs as fast as native SQL query.

 

In the next step, we build a report which compares the results between the two presidential candidates  state by state. The background color indicates the party who won the state.

 

 

The final step consists of chaining together what we have designed in a pipeline, which can be executed as a single unit.

 

 

We hope you enjoyed reading this article. If you have any questions, do not hesitate to contact us.

You can download the Project Zip file by clicking here.

- Stylus Studio Team

Description:<a href= Technical Support
Description: Description: http://www.stylusstudio.com/images/build-dahsboards-xslt/image016.gif Follow us on Twitter
Description: Description: http://www.stylusstudio.com/images/build-dahsboards-xslt/image017.gif Connect on Facebook 

posted on Tuesday, September 18, 2012 2:51:38 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [1] Trackback
# Wednesday, June 13, 2012

Life Cycle of a Purchase Order: EDI X12, XML and PDF

Most of the business transactions B to C (Business to Consumer) today are done by credit card over the web. On the B to B (Business to Business) the volume and the velocity require a different approach, where computer systems do most of the work. These systems are called supply chain networks and their job is to connect buyers and sellers electronically to exchange goods of any kind.

Supply chain networks have existed for many years but were difficult and costly to integrate, which restricted their market to the elite. Their inability to accept medium and small businesses forced a large portion of the supply chain networks out of business.

The survivors learned the lesson and started to offer a scaled down version of their services, increasing the size of their customer base. The larger the network, the greater the chance of success, especially in growing markets such as China and India.

Computer hardware evolves at a fast pace, as Moore’s law states: every two years CPU makers double the number of transistors in a silicon die, improving the lithography process. While IT organizations tend to upgrade their servers every 3 years, data architects are slow to move from time tested successful standards.  These standards provide the back bone of systems’ interoperability.

One of greatest examples of successful standards for data interchange format is Electronic Data Interchange (EDI), created by the National Institute of Standards and Technology (NIST) in 1996.  EDI’s goals were simple: a text based format with a well-defined structure, which allows two entities to exchange information.

The beginning of the formal definition reads: <<”the computer-to-computer interchange of strictly formatted messages that represent documents other than monetary instruments.”>>.

EDI was an instant hit. A variety of standard bodies specialized in industry verticals creating their own dialects. Here are a few examples: 

·         Accredited Standards Committee X12

·         United Nations/Electronic Data Interchange For Administration, Commerce and Transport (UN/EDIFACT)

·         Health Insurance Portability and Accountability Act of 1996 (HIPAA).

EDI is the legacy format that supply chain systems still use today.  Industry specific EDI dialects perform millions of transactions per day.  EDI standards boards have also come out with an XML version of the dialects but the legacy format is still the de-facto standard.

Now in order to participate in these  markets, you have to understand how to interpret EDI transactions, and how to respond to a partner.  Walmart uses EDI to allow it to scale its business, requiring all suppliers to interact with them using EDI to send documents such as Purchase Orders and Invoices. http://www.walmartstores.com/Suppliers/248.aspx

Before we start, let’s refresh our memory on  the definition of a Purchase Order. Wikipedia states:
<<”A purchase order (PO) is a commercial document issued by a buyer to a seller, indicating types, quantities, and agreed prices for products or services the seller will provide to the buyer.”>>

In the following image we see a Purchase Order formatted according to EDI X12 850 in its raw form.

Company “Office Supply” wants to purchase digital pens and appropriate paper blocks from company “Smart Pen” and deliver the products to company “OfficeY”.

Unfortunately, this is not like XML.  You may guess that fields are separated by a special character but there is no markup around them, therefore is very difficult to interpret the values. In the following image we see the same EDI transaction in the Stylus Studio EDI to XML Module.  This is a very useful tool for analyzing EDI documents. We can click anywhere and Stylus Studio shows us which field we are on, thanks to its vast EDI repository. When we right click on a value that represents a code, we can see the description.

Now that the purchase order is in XML we can take advantage of several technologies to manipulate and to store the data.

The EDI to XML module can be used to validate both the structure, the code list values and in case of errors, provide suggestions to work around the problem. For example, it’s quite common to encounter a transaction in which some mandatory fields are missing or the field type does not match the specification. In these situations Stylus Studio flags the error and allows the user to overwrite the field definition to accommodate such customizations.

In Stylus Studio, almost any format can be represented as XML. In the screenshot below the XML Editor is used to edit our purchase order.

The XML representation can be customized with a variety of parameters. You may decide to generate a very verbose form with long element names. You may also use informative comments that provide a detailed description for each field. When looking at code values in the raw form, they are usually very cryptic terms made of a few characters, which can now be associated with detailed descriptions.  The example below shows you that the code value BP stands for “Paid by Buyer”.

 

When an EDI transaction comes in, the first thing we want to do is to archive it in a database. Often there are regulations that require electronic copies to be maintained for several years and storing the transaction in a relation database is the most common place where it can be archived. The following screenshot shows how the Stylus Studio XQuery mapping tool can help you to onboard the transaction into a database. In our example we are using Microsoft SQL Server 2008.

We would like to point out a benefit of using the DataDirect XQuery engine, bundled with Stylus Studio. This combination allows you to store primitive types such as the order id and the order date as well as the entire input document into an XML type column.

 

After the XQuery execution we can see a new record has been created in the table.

EDI and XML share similar benefits. They are great for making computer systems communicate, but human beings need some help to make this information easy to interpret. The following screenshot shows how Stylus Studio XML Publisher can be used to produce an appealing PDF document that can be used to display on the screen and on printed paper.

 

We hope you enjoyed reading this article. If you have any questions, do not hesitate to contact us.

You can download the Project Zip file by clicking here.

- Stylus Studio Team

 Technical Support
 Follow us on Twitter
 Connect on Facebook  

posted on Wednesday, June 13, 2012 2:58:54 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] Trackback