Continued from XML Namespaces for Dummies – Part 1.
Namespaces also give us several brand new opportunities. You may be familiar with ISBN numbers. These numbers give a unique number to every book ever published. What if the Publications Consortium and the Bookshelf Alliance decide they want to include ISBN numbers for their file formats? They can use XML namespaces to announce to the world that the ISBN number schema is actually controlled by someone else. This feature of mixing and matching namespaces is very powerful. The following figure demonstrates how the publications file format might be updated for version 2.0:
Figure 7: Adding a second XML namespace isbn
<publications
xmlns="http://publicationsconsortium.org/schemas/publications_version_2.dtd"
xmlns:isbn="http://schemas.isbn.org/ns/1999/basic.dtd">
...
<book>
<isbn:number>0-393-02039-8</isbn:number>
<field name="title">Adventures of Huckleberry Finn</field>
<field name="author">Mark Twain</field>
<field name="fullTitle">The annotated Huckleberry Finn : Adventures of Huckleberry Finn (Tom Sawyer's comrade)</field>
<description name="shortDescription">
</description>
...
</book>
</publications>
There are a few things to take notice of here. The first is the peculiar definition of the ISBN namespace. Notice how the namespace name is qualified in the format xmlns:isbn. This special format signals that the namespace applies only to elements with the same prefix qualifier–In this case, isbn. Thus, the number element has the isbn prefix, meaning that it is defined by the schema associated with the namespace with that prefix. You can trace the definition back to where it was defined by traveling up the number element's ancestors up to the publications element.
The second thing to notice is that the XML namespace applies to everything within the element. We say that the scope of the XML namespace is the element and its descendent elements. Thus, we can define xmlns:isbn on the publications element, on the book element, or even on the number element, and it is still equivalent because it applies to everything within. Said another way, the number element is in the scope of the xmlns:isbn namespace no matter which of these it is defined on. We might also say that the publications element is the widest scope and that the number element is the narrowest scope. Conventionally, you define namespaces on the top level element because this makes them easiest to find.
Consider how the following are equivalent because of these two rules regarding prefixes and scope:
Figure 8: Equivalent due to prefix equality and namespace scopes
<publications
xmlns="http://publicationsconsortium.org/schemas/publications_version_2.dtd"
xmlns:i="http://schemas.isbn.org/ns/1999/basic.dtd">
...
<book>
<i:number attribute="default">0-393-02039-8</i:number>
...
</book>
</publications>
<publications
xmlns="http://publicationsconsortium.org/schemas/publications_version_2.dtd">
...
<book>
<number xmlns="http://schemas.isbn.org/ns/1999/basic.dtd">0-393-02039-8</number>
...
</book>
</publications>
In the first case, we use the prefix i to define the namespace. This shows that we can use any prefix name that we like when defining a namespace. In the second instance, we define the XML namespace directly on the number element. In this second case, the namespace defined there overrides the namespace defined at a wider scope. That's another rule: namespaces apply to the narrowest scope. We will consider this momentarily when we override namespaces
Let's take a moment from the hows and whys of namespaces to consider how some previously mystifying ideas in XPath are all of a sudden quite mundane.
For instance, namespaces explain why XPath 2.0 functions work. For instance, let's say that we wanted to count the number of books in a bookshelf file:
Figure 9: Using the count function to count the number of books
fn:count(/books/book)
The use of the fn: prefix in XPath 2.0 indicates that a namespace is being used and that the namespace belongs to the consortium originally responsible for XML and XPath. In some reporting tools and XML development environments, you can even define how your own functions but that's beyond the scope of this article.
The use of prefixes was also shown in Figure 6.
There are a few interesting rules when dealing with namespaces. The first is the notion of the default namespace. The original file defined in Figure 1 didn't declare an XML namespace. When no namespace is defined, the default namespace is in effect.
Explicit namespaces are supposed to have schemata, and these schemata can be enforced. Most of the time when you use an explicit XML namespace, if your document does not conform to the schema, it leads to an error being generated. On the other hand, the default namespace doesn't have a schema. More precisely, the default namespace has a schema that says anything goes. This explains why you can create basic XML documents with anything you want in them without errors being generated.
A second interesting idea is the question of attributes. You can also apply namespaces to an attribute by using the prefix notion.
Figure 10: Using attributes in a particular namespace
<books xmlns="http://schemas.bookshelfalliance.org/2011/bookshelf.xsd" xmlns:i="http://schemas.isbn.org/ns/1999/basic.dtd">
...
<book isbn:numberAttribute="0-393-02039-8">
<title >Adventures of Huckleberry Finn</title>
...
</book>
</books>
Ordinarily, attributes belong to the default namespace. They only ever belong to an explicit namespace when xmlns= is used. For instance, in the publications schema, the name attribute on the field element belongs to the http://publicationsconsortium.org/schemas/publications_version_2.dtd namespace. However, when you use prefixes, the attribute belongs to the default namespace. So, in Figure 8, the attribute on the isbn:number element is not in the isbn namespace; it is in the default namespace.
A third advanced idea is the question of the implicit namespace. You might be wondering whether xmlns attribute is simply "magical". What namespace does it belong to? Why can the attribute xmlns:prefix be used? Technically, every XML document defines an XML namespace corresponding to the definition of XML itself. This namespace is implicit, so it is always defined. The xmlns attribute is defined in the schema of this particular namespace. In the case of xmlns:prefix, another implicit namespace defining the schema of XML Namespaces itself also exists. This accounts for the syntax and explains why xmlns is not actually magical.
A fourth and final advanced idea is the idea of reverting to the default namespace. If you define an explicit namespace such as in Figure 7, how can you revert to the default namespace? You do that by adding the attribute xmlns="". In XML Namespace 1.1, a small extension was added that also lets you also revert namespaces with prefixes. For instances xmlns:isbn="" would revert the namespace in Figure 7 back to the default namespace.
XML namespaces are for sharing. Namespaces can be used to mix and match schemata. When combined with XPath, new possibilities of complex and integrated XML files is opened up.
If you've just discovered us, we're excited! Try Windward with our 14-day free trial and start creating documents in quick time with our low/no code solutions.
Adds various capabilities such as inequalities,descending sort, joins, and other functions.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
SQL Select Debugger
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Added a Query tab as a field for typing or pasting in a select statement
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
All tags using that Data source will be automatically updated with that name.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
New single interface to replace 2 separate dialog boxes
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Displays of all the tags in the template, structured as they are placed in the template. This provides a simple & intuitive way to see the structure of your template. Also provides the capability to go to any tag and/or see the properties of any tag.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
The ability to integrate the Windward Engine into Google’s cloud computing platform for developing and hosting web applications dubbed Google Applications Engine (GAE).
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
This new integration will allow for processing of complex scripts and bi-directional text such as Arabic. Your PDF output will be much tighter and more closely match your template, and we’ll be able to respond rapidly to PDF requests and fixes.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Includes support for new ForEach and slide break handling, table header row repeat across slide breaks, and native Microsoft support for charts and images.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Tags are color coded in the template by type, making it easy to visually identify them.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Version 13’s core code has been reworked and optimized to offer a reduced memory footprint, faster PDF generation and full documentation of supported features and limitations in the specifications for DOCX, XLSX and PPTX.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Documents can include advanced Word image properties such as shadows, borders, and styles.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Windward has updated HTML output to reflect changing HTML standards.
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
Windward now works with a slew of new datasources: MongoDB, JSON, Cassandra, OData, Salesforce.com
If you've just discovered us, we're excited. Learn more about Windward document automation software now.
Try Windward with our 30-day free trial and start creating documents in quick time with our low/no code solutions.
The Generate Code tool in the designer allows you to open an existing template and, with a click of a button, automatically create a window with the code needed to run your current template with all data sources and variables. Simply copy this code and paste into your application's code in the appropriate place. You now have Windward integrated into your application.
You only need to do this once. You do not do this for each template. Instead, where it has explicit files for the template and output, change that to parameters you pass to this code. Same for the parameters passed to Windward. This example uses explicit values to show you what to substitute in where.
Any pivot tables in an XLSX template are carried over to the XLSX output. The ranges in the pivot ranges are adjusted to match the generated output. So your final XLSX will have pivot tables set as expected in the generated file.
This makes creating an XLSX workbook with pivot tables trivial.
In an imported sub-template, if its properties for a style (ex. Normal) differ from the parent template's properties for the style, the use in the sub-template can be set to either use the properties in the sub-template, or the properties in the parent.
You set to retain when you don't want the child template's styling to change when imported. You set to use the parent when you want the styling of the imported template to match the styling in the parent.
Any explicit styling is always retained. This only impacts styling set by styles.
Tags can be placed in text boxes. Including linked text boxes. This gives you the ability to set the text in a textbox from your data.
Tags can be placed in shapes & smart art. This gives you the ability to set the text in a shape from your data.
When generating HTML output, the engine can either write bitmaps as distinct files the generate HTML references, or it can embed the images in the HTML providing a single file for the output.
You can place tags in pretty much any part of a template, including in footnotes & endnotes.
Any parts of a DOCX or XLSX (PowerPoint does not support this) file that are locked in the template, will be locked the same in the output.
If a font used in the template does not exist on the server generating a report, the font to substitute can be specified.
In addition, if a glyph to be rendered does not exist in the font specified, you can specify the replacement font. This can be set distinctly for European, Bi-Directional, and Far East fonts.
If you need this - it's essential. And if you don't need it, it's irrelevant.
Windward enables you to build a document by applying multiple datasources to the template simultaneously. When Windward is merging the data into a template, it processes the template by handling each tag in order, and each tag pulls from different datasources. (As opposed to processing all of one datasource, then processing the next.)
This allows the select tag to use data from another datasource in its select. For example, if you are pulling customer information from one data source, you can then pull data from the sales datasource using the customer ID of the customer presently processing to pull the sales information for that customer. If you're interested in patching together your data from multiple datasources, read this post on our blog.