I am having a Java Object which is ArrayList and i have added it in response of service which is in XML format as below,
<root>
<SubRoot>
<type>A</type>
<mand>Y</mand>
<Section>B</Section>
</SubRoot>
<SubRoot>
<type>A</type>
<mand>Y</mand>
<Section>A</Section>
</SubRoot>
</root>
I am trying to use the some value from above xml for condition.On basis of true condition i will call some template for my purpose.
I am calling my xsl template as below,
<xsl:choose>
<xsl:when test="(/root/SubRoot[Section = 'A'])">
//Call some template
</xsl:when>
<xsl:otherwise>
//some template
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="(/root/SubRoot[Section = 'B'])">
//call some template
</xsl:when>
<xsl:otherwise>
//some template
</xsl:otherwise>
</xsl:choose>
Each time my first when will get executed its not coming inside the second when condition.
Could you please help me how the both condition will get executed?is it right approach in terms of performance?
Any Suggestion approach must be appreciated.
Try this,
XSL
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://locomotive/bypass/docx">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" />
<xsl:strip-space elements="*" />
<!-- identity transform -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="SubRoot">
<xsl:choose>
<xsl:when test="Section = 'A'">
<!-- your logic for A -->
<A></A>
</xsl:when>
<xsl:otherwise>
<!-- your logic for B -->
<B></B>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
XML
<root>
<SubRoot>
<type>A</type>
<mand>Y</mand>
<Section>B</Section>
</SubRoot>
<SubRoot>
<type>A</type>
<mand>Y</mand>
<Section>A</Section>
</SubRoot>
Demo link : http://xsltransform.net/ejivdHb/15
Related
I'm trying to generate an xml with the help of xslt templates and I have a tricky thing to do:
I have to generate a certain number of elements that have same tags but with different values inside them. Example of xslt stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="NbOfBatches"/>
<xsl:param name="wholeTag"/>
<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<Document xmlns="urn:something" xmlns:file="someUrn>
<FileAppHdr>
<file:NbOfBatches><xsl:value-of select="$NbOfBatches"></xsl:value-of></file:NbOfBatches>
<xsl:call-template name="selects">
<xsl:with-param name="i">1</xsl:with-param>
<xsl:with-param name="count"><xsl:value-of select="$NbOfBatches"/></xsl:with-param>
</xsl:call-template>
</FileAppHdr>
</Document>
</xsl:template>
<xsl:template name="selects">
<xsl:param name="i" />
<xsl:param name="count" />
<xsl:if test="$i <= $count">
<xsl:call-template name="credit">
<xsl:with-param name="param0"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$i <= $count">
<xsl:call-template name="selects">
<xsl:with-param name="i">
<xsl:value-of select="$i + 1"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="credit">
<xsl:param name="param0"/>
<CreditTransfer>
<xsl:value-of select="$param0"/>
</CreditTransfer>
</xsl:template>
</xsl:stylesheet>
In this way, I can use Saxon or JAXP and call .setParameter() for NbOfBatches, it will generate that number of tags. However is there a way to generate / modify name of param0 inside CreditTransfer so that I can loop through data in Java and use .setParameter("param1", value1) and so on ?
Thank you
Rather than trying to pass structured data as a stylesheet parameter, why not generate that structured data as XML and pass that XML document as the source document of the transformation?
As an example, imagine a source XML document with param0 in each Batch:
<Batches>
<Batch>
<param0>it was the best of times</param0>
</Batch>
<Batch>
<param0>it was the worst of times</param0>
</Batch>
<Batch>
<param0>it was the age of wisdom</param0>
</Batch>
<Batch>
<param0>it was the age of foolishness</param0>
</Batch>
</Batches>
with a simplified version of your stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<Document xmlns:file="someUrn">
<FileAppHdr>
<file:NbOfBatches><xsl:value-of select="count(//Batch)"/></file:NbOfBatches>
<xsl:for-each select="//Batch">
<xsl:call-template name="selects">
<xsl:with-param name="param0" select="param0" />
</xsl:call-template>
</xsl:for-each>
</FileAppHdr>
</Document>
</xsl:template>
<xsl:template name="selects">
<xsl:param name="param0" />
<xsl:call-template name="credit">
<xsl:with-param name="param0" select="$param0" />
</xsl:call-template>
</xsl:template>
<xsl:template name="credit">
<xsl:param name="param0"/>
<CreditTransfer>
<xsl:value-of select="$param0"/>
</CreditTransfer>
</xsl:template>
</xsl:stylesheet>
produces this output:
<Document xmlns:file="someUrn">
<FileAppHdr>
<file:NbOfBatches>4</file:NbOfBatches>
<CreditTransfer>it was the best of times</CreditTransfer>
<CreditTransfer>it was the worst of times</CreditTransfer>
<CreditTransfer>it was the age of wisdom</CreditTransfer>
<CreditTransfer>it was the age of foolishness</CreditTransfer>
</FileAppHdr>
</Document>
It's fairly trivial to generate XML from structured data in Java using the Saxon sapling classes. https://www.saxonica.com/html/documentation10/javadoc/net/sf/saxon/sapling/package-summary.html
<?xml version="1.0" encoding="UTF-8"?>
<FirstTag version="1.0" createTime="15:59:59" DATE="20161209">
<SecondTag Name="House01">
<a>
<Furniture FURN_ID="FUR00001" FURN_AMT="2" price="10000"/>
<Furniture FURN_ID="FUR00002" FURN_AMT="1" price="20000"/>
</a>
<b>
<Furniture FURN_ID="FUR00003" FURN_AMT="2" price="30000"/>
<Furniture FURN_ID="FUR00004" FURN_AMT="1" price="40000"/>
</b>
<c>
<Furniture FURN_ID="FUR00005" FURN_AMT="2" price="50000"/>
<Furniture FURN_ID="FUR00006" FURN_AMT="1" price="60000"/>
</c>
<d>
<Furniture FURN_ID="FUR00007" FURN_AMT="1" price="70000"/>
<Furniture FURN_ID="FUR00008" FURN_AMT="1" price="80000"/>
</d>
<e>
<Furniture FURN_ID="FUR00009" FURN_AMT="1" price="90000"/>
<Furniture FURN_ID="FUR00010" FURN_AMT="1" price="100000"/>
</e>
<f>
<Furniture FURN_ID="FUR00011" FURN_AMT="1" price="110000"/>
<Furniture FURN_ID="FUR00012" FURN_AMT="2" price="120000"/>
<Furniture FURN_ID="FUR00013" FURN_AMT="2" price="120000"/>
</f>
</SecondTag>
</FirstTag>
Above is the simple xml (with node value), that I produced from my Java program. The point is, I want to send this xml data to another application, where there's already a csv load function from the UI/batch processes. I've heard of XSLT but never use of it, tried some of the tutorial but got confused in the time to get all the values into a csv.
Here's what it should look like in csv (to start, after success need to do some calculation):
In this example in one house (HOUSE01) I would like to output all the furniture in different room (i.e. a is room 1, b is room 2, c is room 3, etc).
I've been trying to build the XSLT, below is the XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="delimiter" select="','" />
<!-- define an array containing the fields we are interested in -->
<xsl:variable name="fieldArray">
<field>Name</field>
<field>a</field>
<field>b</field>
<field>c</field>
<field>d</field>
<field>e</field>
<field>f</field>
</xsl:variable>
<xsl:param name="fields" select="document('')/*/xsl:variable[#name='fieldArray']/*" />
<xsl:template match="/">
<!-- output the header row -->
<xsl:for-each select="$fields">
<xsl:if test="position() != 1">
<xsl:value-of select="$delimiter"/>
</xsl:if>
<xsl:value-of select="." />
</xsl:for-each>
<!-- output newline -->
<xsl:text>
</xsl:text>
<xsl:apply-templates select="/*/*"/>
</xsl:template>
<xsl:template match="a">
<xsl:variable name="currNode" select="." />
<!-- output the data row -->
<!-- loop over the field names and find the value of each one in the xml -->
<xsl:for-each select="$fields">
<xsl:if test="position() != 1">
<xsl:value-of select="$delimiter"/>
</xsl:if>
<xsl:value-of select="$currNode/*[name() = current()]/#FURN_ID" />
<!-- <xsl:value-of select="$currNode/*[name() = current()]" /> -->
</xsl:for-each>
<!-- output newline -->
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
I'm using some reference from another page, and can build some simple XSLT to transform XML to CSV, however, I need some guidance in order to solve my main XML issue. In the future after I can get the node value inside the loop, I'd like to sum the total price of every furniture for each room.
Expected final csv result:
Name,a,b,c,d,e,f
House01,40000,100000,160000,150000,190000,350000
Thank you.
Getting the value of an attribute in XML
This XSLT will give the output you specified. See demo.
Updated: I missed the a value in the output.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="/">
<xsl:text>Name,a,b,c,d,e,f
</xsl:text>
<xsl:apply-templates select="FirstTag/SecondTag/a/Furniture"/>
</xsl:template>
<xsl:template match="Furniture">
<xsl:variable name="pos" select="position()"/>
<xsl:value-of select="../../#Name"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="#FURN_ID"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="../../b/Furniture[position()=$pos]/#FURN_ID"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="../../c/Furniture[position()=$pos]/#FURN_ID"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="../../d/Furniture[position()=$pos]/#FURN_ID"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="../../e/Furniture[position()=$pos]/#FURN_ID"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="../../f/Furniture[position()=$pos]/#FURN_ID"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
The second (final) .csv can be produced as follows:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="text" encoding="UTF-8" />
<xsl:template match="/FirstTag">
<!-- first pass -->
<xsl:variable name="values-rtf">
<xsl:for-each select="SecondTag/*">
<xsl:copy>
<xsl:for-each select="Furniture">
<value>
<xsl:value-of select="#FURN_AMT * #price"/>
</value>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="values" select="exsl:node-set($values-rtf)/*" />
<!-- header -->
<xsl:text>Name,</xsl:text>
<xsl:for-each select="$values">
<xsl:value-of select="name()"/>
<xsl:if test="position()!=last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>
</xsl:text>
<!-- summary -->
<xsl:value-of select="SecondTag/#Name"/>
<xsl:text>,</xsl:text>
<xsl:for-each select="$values">
<xsl:value-of select="sum(value)"/>
<xsl:if test="position()!=last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This assumes you are limited to XSLT 1.0; in XSLT 2.0 this could be done in a single pass.
Note that I am assuming the input XML will contain a single "house" (SecondTag), with a variable number of "rooms" (a, b, c, etc.). Otherwise it's not clear what the header of the .csv should be.
I am not sure if you need to also have the interim .csv - and in any case, the logic required to create it is not clear (why is FUR00013 missing from the output?).
I have a text file as given below:
value1 value2 value3 value4
I want to convert it as following xml using XSLT
<values>
<value>value1</value>
<value>value2</value>
<value>value3</value>
<value>value4</value>
</values>
Thanks in advance.
Assuming XSLT 2.0,
<xsl:template name="main">
<values>
<xsl:for-each select="tokenize(unparsed-text('input.txt'), '\s+')">
<value><xsl:value-of select="."/></value>
</xsl:for-each>
</values>
</xsl:template>
if you can edit your input such that it contains a root element, and a tab character as a separator, such as below:
<root>value1 value2 value3 value4</root>
then, you can apply the following stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<values>
<xsl:call-template name="tokenizeString">
<xsl:with-param name="list" select="."/>
<xsl:with-param name="delimiter" select="' '"/>
</xsl:call-template>
</values>
</xsl:template>
<xsl:template name="tokenizeString">
<!--passed template parameter -->
<xsl:param name="list"/>
<xsl:param name="delimiter"/>
<xsl:choose>
<xsl:when test="contains($list, $delimiter)">
<value>
<!-- get everything in front of the first delimiter -->
<xsl:value-of select="substring-before($list,$delimiter)"/>
</value>
<xsl:call-template name="tokenizeString">
<!-- store anything left in another variable -->
<xsl:with-param name="list" select="substring-after($list,$delimiter)"/>
<xsl:with-param name="delimiter" select="$delimiter"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$list = ''">
<xsl:text/>
</xsl:when>
<xsl:otherwise>
<value>
<xsl:value-of select="$list"/>
</value>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
and produce:
<values>
<value>value1</value>
<value>value2</value>
<value>value3</value>
<value>value4</value>
</values>
Using http://xslt.online-toolz.com/tools/xslt-transformation.php
.xml
<?xml version="1.0"?>
<my:project xmlns:my="http://myns">
<my:properties>
<my:property>
<my:name>customerId</my:name>
<my:value>1</my:value>
</my:property>
<my:property>
<my:name>userId</my:name>
<my:value>20</my:value>
</my:property>
</my:properties>
</my:project>
I now want to look for the name customerId and want to replace the value.
It almost works, but it replaces ALL values in the document. What am I doing wrong to just replace the value where the name mached?
.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://myns" xmlns:saxon="http://saxon.sf.net">
<xsl:param name="name" select="'customerId'"/>
<xsl:param name="value" select="'0'"/>
<xsl:template match="node() | #*">
<xsl:copy>
<xsl:apply-templates select="node() | #*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*/my:properties/my:property/my:value/text()" >
<xsl:choose>
<xsl:when test="/*/my:properties/my:property/my:name = $name">
<xsl:value-of select="$value"/>
</xsl:when>
<xsl:otherwise><xsl:copy-of select="saxon:parse(.)" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
The test for /*/my:properties/my:property/my:name = $name always succeed because it uses an absolute path, and so the result is independent of the surrounding template context. A test with a relative xpath should work.
XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="http://myns" xmlns:saxon="http://saxon.sf.net">
<xsl:param name="name" select="'customerId'"/>
<xsl:param name="value" select="'0'"/>
<xsl:template match="node() | #*">
<xsl:copy>
<xsl:apply-templates select="node() | #*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*/my:properties/my:property/my:value/text()" >
<xsl:choose>
<xsl:when test="../../my:name = $name">
<xsl:value-of select="$value"/>
</xsl:when>
<xsl:otherwise>otherwise</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
XML:
<my:project xmlns:my="http://myns">
<my:properties>
<my:property>
<my:name>customerId</my:name>
<my:value>1</my:value>
</my:property>
<my:property>
<my:name>userId</my:name>
<my:value>20</my:value>
</my:property>
</my:properties>
</my:project>
Result of saxonb-xslt -s:test.xml -xsl:test.xsl
<my:project xmlns:my="http://myns">
<my:properties>
<my:property>
<my:name>customerId</my:name>
<my:value>0</my:value>
</my:property>
<my:property>
<my:name>userId</my:name>
<my:value>otherwise</my:value>
</my:property>
</my:properties>
</my:project>
I am trying to develop an XSLT custom function that could return node set or an XML fragment, let's say something like:
Input document:
<root>
<!--
author: blablabla
usage: more blablabla
labelC: [in=2] <b>formatted</b> blablabla
-->
<tag1 name="first">
<tag2>content a</tag2>
<tag2>content b</tag2>
<tag3 attrib="val">content c</tag3>
</tag1>
<!--
author: blebleble
usage: more blebleble
labelC: blebleble
-->
<tag1 name="second">
<tag2>content x</tag2>
<tag2>content y</tag2>
<tag3 attrib="val">content z</tag3>
</tag1>
</root>
So that an XSLT template such as:
<xsl:template match="//tag1/preceding::comment()[1]" xmlns:d="java:com.dummy.func">
<section>
<para>
<xsl:value-of select="d:genDoc(.)"/>
</para>
</section>
</xsl:template>
Would produce:
<section>
<para>
<author>blablabla</author>
<usage>more blablabla</usage>
<labelC in="2"><b>formatted</b> blablabla</labelC>
</para>
</section>
When matched on the first occurrence of tag1
and
<section>
<para>
<author>blebleble</author>
<usage>more blebleble</usage>
<labelC>blebleble</labelC>
</para>
</section>
When matched on the second occurrence.
Basically what I want to achieve with this custom function is to parse some meta-data present in the comments and use it to generate XML.
I found some examples online, one at:
http://cafeconleche.org/books/xmljava/chapters/ch17s03.html
According to the example, my function should return one of the following
org.w3c.dom.traversal.NodeIterator,
org.apache.xml.dtm.DTM,
org.apache.xml.dtm.DTMAxisIterator,
org.apache.xml.dtm.DTMIterator,
org.w3c.dom.Node and its subtypes (Element, Attr, etc),
org.w3c.dom.DocumentFragment
I was able to implement a function returning the XML as simple type String.
This, however poses several other problems: the main being the markers characters get escaped when inserted in the original XML.
Does anybody have an example of how to implement such function?
I am mostly interested in how to return a proper XML node set to the calling template.
The below may get you a long way along the road you want to go. Note that this requires XSLT 2.0 version (in XSLT 1.0 it will be possible too, when supplying a replacement function for tokenize). Also note that this assumes a specific comment contents structure.
Explanation: comments are first split up into rows (delimiter & #xD; which is a line-feed), then in tag+value (delimiter ":", splitting into author, usage, labelC, the order is not important here), then in attributes and value for labelC (delimiter "] ", recognizing attributes as starting with "[").
Note that a lot of whitespace-wiping is done using normalize-space().
Edited: xslt version with function see at the bottom
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<output>
<xsl:apply-templates/>
</output>
</xsl:template>
<xsl:template match="tag1/*">
</xsl:template>
<xsl:template match="comment()">
<section>
<para>
<xsl:for-each select="tokenize(., '
')[string-length() != 0]">
<xsl:variable name="splitup" select="tokenize(normalize-space(current()), ':')"/>
<xsl:choose>
<xsl:when test="$splitup[1]='author'">
<author><xsl:value-of select="normalize-space($splitup[2])"/></author>
</xsl:when>
<xsl:when test="$splitup[1]='usage'">
<usage><xsl:value-of select="normalize-space($splitup[2])"/></usage>
</xsl:when>
<xsl:when test="$splitup[1]='labelC'">
<labelC>
<xsl:for-each select="tokenize($splitup[2], '] ')[string-length() != 0]">
<xsl:variable name="labelCpart" select="normalize-space(current())"/>
<xsl:choose>
<xsl:when test="substring($labelCpart, 1,1) = '['">
<xsl:variable name="attr" select="tokenize(substring($labelCpart, 2), '=')"/>
<xsl:attribute name="{$attr[1]}"><xsl:value-of select="$attr[2]"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$labelCpart"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</labelC>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</para>
</section>
</xsl:template>
</xsl:stylesheet>
when applied to the following XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<!--
author: blablabla
usage: more blablabla
labelC: [in=2] <b>formatted</b> blablabla
-->
<tag1 name="first">
<tag2>content a</tag2>
<tag2>content b</tag2>
<tag3 attrib="val">content c</tag3>
</tag1>
<!--
author: blebleble
usage: more blebleble
labelC: blebleble
-->
<tag1 name="second">
<tag2>content x</tag2>
<tag2>content y</tag2>
<tag3 attrib="val">content z</tag3>
</tag1>
</root>
gives the following output
<?xml version="1.0" encoding="UTF-8"?>
<output>
<section>
<para>
<author>blablabla</author>
<usage>more blablabla</usage>
<labelC in="2"><b>formatted</b> blablabla</labelC>
</para>
</section>
<section>
<para>
<author>blebleble</author>
<usage>more blebleble</usage>
<labelC>blebleble</labelC>
</para>
</section>
</output>
EDITED xslt with function call (gives the same output)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:d="java:com.dummy.func"
exclude-result-prefixes="d">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<output>
<xsl:apply-templates/>
</output>
</xsl:template>
<xsl:template match="tag1/*">
</xsl:template>
<xsl:function name="d:section">
<xsl:param name="comm"/>
<section>
<para>
<xsl:for-each select="tokenize($comm, '
')[string-length() != 0]">
<xsl:variable name="splitup" select="tokenize(normalize-space(current()), ':')"/>
<xsl:choose>
<xsl:when test="$splitup[1]='author'">
<author><xsl:value-of select="normalize-space($splitup[2])"/></author>
</xsl:when>
<xsl:when test="$splitup[1]='usage'">
<usage><xsl:value-of select="normalize-space($splitup[2])"/></usage>
</xsl:when>
<xsl:when test="$splitup[1]='labelC'">
<labelC>
<xsl:for-each select="tokenize($splitup[2], '] ')[string-length() != 0]">
<xsl:variable name="labelCpart" select="normalize-space(current())"/>
<xsl:choose>
<xsl:when test="substring($labelCpart, 1,1) = '['">
<xsl:variable name="attr" select="tokenize(substring($labelCpart, 2), '=')"/>
<xsl:attribute name="{$attr[1]}"><xsl:value-of select="$attr[2]"/></xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$labelCpart"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</labelC>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</para>
</section>
</xsl:function>
<xsl:template match="comment()">
<xsl:copy-of select="d:section(.)"/>
</xsl:template>
</xsl:stylesheet>