Author Archives: Kiril Kirov - Page 2

Controlling break space and white space in XSLT output



<xsl:output method=”xml” indent=”yes”/>

Saying indent=”yes” in xsl:output allows the processor to indent the output any way it chooses. If you don’t want that, don’t specify indent=”yes”; you will then get no extra whitespace in the output unless you create it explicitly using <xsl:value-of> or <xsl:text>.

If you want more intelligent formatting, you can use Saxon in schema-aware mode, validating the output against a schema. It will then avoid applying indentation to elements that are defined in the schema to have a mixed content model, which seems to be the effect you are looking for here.

———————————————–

<xsl:variable name=”newline”>
<xsl:text>
</xsl:text>
</xsl:variable>


usage:
<xsl:value-of select=”$newline”> <!– line break in output file –>

———————————————–
http://www.ibm.com/developerworks/xml/library/x-tipwhitesp.html


<xsl:template match=”/”>
<faqoutput><xsl:text>
  </xsl:text><info xml:space=”preserve”>
     <title xml:space=”default”>
       <xsl:value-of select=”faqs/question/questiontitle”/>
     </title>
  </info>
  <xsl:apply-templates/>
</faqoutput>
</xsl:template>

————————————————
<xsl:text> </xsl:text>

————————————————

Use <xsl:text></xsl:text> to contain literal white space;
you can even do something clever like <xsl:text>
</xsl:text> to send just a newline, or <xsl:text> </xsl:text>
to send five blanks.

And if you use <xsl:if test=…>, you can send your literal
output based on an arbitrary condition.

XML Course 8

The purpose of this week’s mind bogglin’ xml session will be our first encounter with XQuery.
We can start with few valuable links to XQuery resources we are going to use:

  1. An example interface running XQueries on a real database – here
  2. A tutorial on XQuery from some Stylus Studio promoters, but it’s rather good – here
  3. Another XQuery tutorial from the W3Schools – here
  4. A reference of XPath expression functions we might use some day :) or right now
And here is the actual W3C specification of XQuery

This weeks materials course8_xqueryHERE!

Course 7

The output xsl code from course 6:

is here!

—————-
XPath Cheat Sheet : xml-path-language-10

XSLT Cheat Sheet : xslt_1quickref-v2

XML Course 6

The materials needed:
course6

XML 5

Some links that are of interest for the course.

An xsl overview on slides – here

Zvon xml namespace tutorial – here

Zvon XML Schema tutorial – here

Zvon xslt tutorial – here

We need to learn how:

1. To write XSD includes
2. Use multiple xml schema includes with different namespaces
3. Validate the content of our XML before doing the transformation.

4. Define the diference between XSLT with recursion and straith forward transformation

: xsl :value-of ...
: xsl:call-template
: xsl:apply-templates select="" mode=""
: xsl:for-each
: xsl:if
Tags: ,