xslt mapping - DB collections - xslt-1.0

Actually am novice to XSLT. I have dome simple transformations using JDeveloper with for each loop while handling DB ouputs.
My current business needs an select on condition base. I have the following input xml
<?xml version = '1.0' encoding = 'UTF-8'?>
<response>
<head>
<headSeq>101</headSeq>
<date>12/03/2018</date>
</head>
<lines>
<lineItem>
<lineId>L101</lineId>
<item>Laptop</item>
<itemName>Dell</itemName>
<cId>201</cId>
</lineItem>
<lineItem>
<lineId>L102</lineId>
<item>Laptop</item>
<itemName>Dell</itemName>
<cId>202</cId>
</lineItem>
<lineItem>
<lineId>L103</lineId>
<item>Laptop</item>
<itemName>Dell</itemName>
<cId>202</cId>
</lineItem>
</lines>
<configs>
<configItem>
<configId>201</configId>
<configName>I3</configName>
</configItem>
<configItem>
<configId>202</configId>
<configName>I5</configName>
</configItem>
</configs>
</response>
Required output is
<?xml version = '1.0' encoding = 'UTF-8'?>
<ns0:lineTblRoot>
<ns0:lineTbl>
<ns0:headSeq>101</ns0:headSeq>
<ns0:lineId>L101</ns0:lineId>
<ns0:item>Laptop</ns0:item>
<ns0:itemName>Dell</ns0:itemName>
<ns0:configId>201</ns0:configId>
<ns0:configName>I3</ns0:configName>
</ns0:lineTbl>
<ns0:lineTbl>
<ns0:headSeq>101</ns0:headSeq>
<ns0:lineId>L102</ns0:lineId>
<ns0:item>Laptop</ns0:item>
<ns0:itemName>Dell</ns0:itemName>
<ns0:configId>202</ns0:configId>
<ns0:configName>I5</ns0:configName>
</ns0:lineTbl>
<ns0:lineTbl>
<ns0:headSeq>101</ns0:headSeq>
<ns0:lineId>L103</ns0:lineId>
<ns0:item>Laptop</ns0:item>
<ns0:itemName>Dell</ns0:itemName>
<ns0:configId>202</ns0:configId>
<ns0:configName>I5</ns0:configName>
</ns0:lineTbl>
</ns0:lineTblRoot>
The following XSLT doesn't yield proper result.
<xsl:template match="/">
<ns0:lineTblRoot>
<xsl:for-each select="/ns0:response/ns0:lines/ns0:lineItem">
<ns0:lineTbl>
<ns0:headSeq>
<xsl:value-of select="/ns0:response/ns0:head/ns0:headSeq"/>
</ns0:headSeq>
<ns0:lineId>
<xsl:value-of select="ns0:lineId"/>
</ns0:lineId>
<ns0:item>
<xsl:value-of select="ns0:item"/>
</ns0:item>
<ns0:itemName>
<xsl:value-of select="ns0:itemName"/>
</ns0:itemName>
<ns0:configId>
<xsl:value-of select="ns0:cId"/>
</ns0:configId>
<xsl:for-each select="/ns0:response/ns0:configs/ns0:configItem">
<xsl:choose>
<xsl:when test="/ns0:response/ns0:lines/ns0:lineItem/ns0:cId = /ns0:response/ns0:configs/ns0:configItem/ns0:configId"/>
</xsl:choose>
</xsl:for-each>
<ns0:configName>
<xsl:value-of select="/ns0:response/ns0:configs/ns0:configItem/ns0:configName"/>
</ns0:configName>
</ns0:lineTbl>
</xsl:for-each>
</ns0:lineTblRoot>
</xsl:template>
Need to select configName based on the cId in lineItem on matches with configID from configItem.
Am I miss something here? Please help.

You are matching the element with namespaces but input doesnot contains any namespaces, Use this code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://xmlns.telenet.be/messages/GN/v001"
exclude-result-prefixes="ns0">
<xsl:template match="/">
<ns0:lineTblRoot>
<xsl:for-each select="descendant::lineItem">
<xsl:variable name="cId" select="cId"/>
<ns0:lineTbl>
<ns0:headSeq>
<xsl:value-of select="//response/head/headSeq"/>
</ns0:headSeq>
<ns0:lineId>
<xsl:value-of select="lineId"/>
</ns0:lineId>
<ns0:item>
<xsl:value-of select="item"/>
</ns0:item>
<ns0:itemName>
<xsl:value-of select="itemName"/>
</ns0:itemName>
<ns0:configId>
<xsl:value-of select="//configs/configItem/configId[. = $cId]"/>
</ns0:configId>
<ns0:configName>
<xsl:value-of select="//configs/configItem[configId = $cId]/configName"/>
</ns0:configName>
</ns0:lineTbl>
</xsl:for-each>
</ns0:lineTblRoot>
</xsl:template>
</xsl:stylesheet>

Related

Apply templates that matchs two conditions

I need to list all the INST names but only if the "onlyTesters" node don´t exists in the "inst/idef" part of XML body above.
I know thats strange but I can´t change the XML I receive.
XML:
<river>
<station num="699">
<inst name="FLU(m)" num="1">
<idef></idef>
</inst>
<inst name="Battery(V)" num="18">
<idef>
<onlyTesters/>
</idef>
</inst>
</station>
<INST name="PLU(mm)" num="0" hasData="1" virtual="0"/>
<INST name="FLU(m)" num="1" hasData="1" virtual="0"/>
<INST name="Q(m3/s)" num="3" hasData="1" virtual="1"/>
<INST name="Battery(V)" num="18" hasData="1" virtual="0"/>
</river>
XSL:
<xsl:template match="/">
<xsl:apply-templates select="//INST[#hasData = 1 and not(//inst[#num=(current()/#num)]/idef/onlyTesters)]/#name"/>
</xsl:template>
<xsl:template match="//INST[#hasData = 1 and not(//inst[#num=(current()/#num)]/idef/onlyTesters)]/#name">
<xsl:value-of select="#name"/>,
</xsl:template>
I´m having no match.
This is the result I expect:
PLU(mm),FLU(m),Q(m3/s)
You can achieve this with only one template:
<xsl:template match="/">
<xsl:for-each select="//INST[#hasData='1' and not(#name=//inst[idef/onlyTesters]/#name)]">
<xsl:value-of select="#name"/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:template>
Output is:
PLU(mm), FLU(m), Q(m3/s)
Cross-references are best resolved using a key - for example:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:key name="inst" match="inst" use="#name" />
<xsl:template match="/river">
<xsl:for-each select="INST[#hasData = 1 and not(key('inst', #name)/idef/onlyTesters)]">
<xsl:value-of select="#name"/>
<xsl:if test="position() != last()">,</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Or even simpler:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" />
<xsl:key name="exclude" match="onlyTesters" use="ancestor::inst/#name" />
<xsl:template match="/river">
<xsl:for-each select="INST[#hasData = 1 and not(key('exclude', #name))]">
<xsl:value-of select="#name"/>
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

How to Parse Query parameters in XSLT

I have a requirement I will get the URL in the format like this below
https://sample.com?first=one&second=two&third=three
How can I form an xml structure below which will be formed by making use of this query parameters
<first>one</first><second>two</second><third>three</third>
can Please somebody help me with thisand provide me an xslt for this requirement
Given the following XML input (note the escaping of the ampersand character):
<URL>https://sample.com?first=one&second=two&third=three</URL>
the folowing stylesheet:
XSLT 1.0
<xsl:stylesheet version="1.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:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after(URL, '?')"/>
</xsl:call-template>
</output>
</xsl:template>
<xsl:template name="tokenize">
<xsl:param name="text"/>
<xsl:param name="delimiter" select="'&'"/>
<xsl:variable name="token" select="substring-before(concat($text, $delimiter), $delimiter)" />
<xsl:if test="$token">
<xsl:element name="{substring-before($token, '=')}">
<xsl:value-of select="substring-after($token, '=')"/>
</xsl:element>
</xsl:if>
<xsl:if test="contains($text, $delimiter)">
<!-- recursive call -->
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after($text, $delimiter)"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
will return:
<?xml version="1.0" encoding="UTF-8"?>
<output>
<first>one</first>
<second>two</second>
<third>three</third>
</output>
Note that this will work only if the query field names are also valid XML element names.

Iterate through xml nodes within XSLT

With in an xslt 1.0. I am calling a java function getTierByBundleId which returns below xml. I want to iterate through each Tier using for each. How can i do that
<xsl:variable name="varTierList" select="testclass:getTierByBundleId($bid,$ApplicationId)"/>
Xml returned by function getTierByBundleId
<TierList>
<Tier>
<TierId>1</TierId>
<Name>test</Name>
<Type>2</Type>
<Price>10</Price>
</Tier>
<Tier>
<TierId>2</TierId>
<Name>test</Name>
<Type>3</Type>
<Price>11</Price>
</Tier>
</TierList>
Here when I am trying to do xsl:for each on the variable which has the xml I am getting compilation error. How can I access each Tier from variable $varTierList
<xsl:for-each select="$varTierList/TierList/Tier">
<TierId><xsl:for each"Tierid"/>
</xsl:for-each
Below is the xslt which is generation the above TierList xml
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:foxtelclass="test.GetOrderQuote" exclude-result-prefixes="foxtelclass" extension-element-prefixes="testclass">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:if test="count(/ROWSET/ROW) > 0">
<TierList>
<xsl:for-each select="/ROWSET/ROW">
<Tier>
<TierId><xsl:value-of select="TIER_ID" /></TierId>
<Name><xsl:value-of select="NAME" /></Name>
<Type><xsl:value-of select="TIER_TYPE" /></Type>
<Price><xsl:value-of select="PRICE" /></Price>
</Tier>
</xsl:for-each>
</TierList>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
<xsl:for-each select="$varTierList/TierList/Tier"> is throwing the error message
Here is the full xslt
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:testclass="test.GetOrderQuote"
xmlns:ext="http://exslt.org/common" exclude-result-prefixes="testclass" extension-
element-prefixes="testclass">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="ApplicationId"/>
<xsl:template match="/">
<ServiceList>
<xsl:variable name="unique-list" select="//ROWSET/ROW/SERVICE_ID
[not(.=following::SERVICE_ID)]"/>
<xsl:for-each select="$unique-list">
<xsl:if test=".!=0">
<Service>
<xsl:variable name="Sid" select="."/>
<ServiceInternalId>
<xsl:value-of select="."/>
</ServiceInternalId>
<BundleList>
<xsl:variable name="unique-
bundle" select="//SERVICE_ID/../BUNDLE_ID[not(.=following::BUNDLE_ID)]"/>
<xsl:for-each
select="$unique-bundle">
<xsl:variable
name="bid" select="."/>
<xsl:if
test="count(/ROWSET/ROW/SERVICE_ID[text()=$Sid]/../BUNDLE_ID[text()=$bid])> 0">
<Bundle>
<Bundle_Id>
<xsl:value-of select="$bid"/>
</Bundle_Id>
<Type>
<xsl:value-of select="../BUNDLE_TYPE"/>
</Type>
<Name>
<xsl:value-of select="../BUNDLE_NAME"/>
</Name>
<Price>
<xsl:value-of select="../BUNDLE_PRICE"/>
</Price>
<xsl:variable name="varTierList" select="testclass:getTierByBundleId
($bid,$ApplicationId)"/>
<test>
<xsl:value-of select="$varTierList"/>
</test>
<xsl:for-each select="$varTierList/TierList/Tier"><!--line causing error-->
<TierId>
<xsl:value-of select="TierId"/>
</TierId>
</xsl:for-each>
</Bundle>
</xsl:if>
</xsl:for-each>
</BundleList>
</Service>
</xsl:if>
</xsl:for-each>
</ServiceList>
</xsl:template>
</xsl:stylesheet>
Below is the text from test node which what is xml variable varTierList contains
<test><TierList>
<Tier>
<TierId>109</TierId>
<Name>Boxes</Name>
<Type>10</Type>
<Price>10</Price>
</Tier>
</TierList>
</test>
Please find below input xml
<ROWSET>
<ROW>
<SET_ID>0</SET_ID>
<SET_DATE>2014-11-09 00:00:00.0</SET_DATE>
<BUNDLE_NAME>Test</BUNDLE_NAME>
<BUNDLE_ID>131</BUNDLE_ID>
<BUNDLE_PRICE>30</BUNDLE_PRICE>
<BUNDLE_TYPE>3</BUNDLE_TYPE>
<BUNDLECOMPONENT_LIST>101100</BUNDLECOMPONENT_LIST>
<PACKAGE>10015</PACKAGE>
<PACKAGE_TYPE>5</PACKAGE_TYPE>
<COMPONENT>101100</COMPONENT>
<PRODUCT_DESC>World Movies</PRODUCT_DESC>
<RATE_AMOUNT>10</RATE_AMOUNT>
<DISCOUNT_AMOUNT>0</DISCOUNT_AMOUNT>
<SERVICE_ID>98683812</SERVICE_ID>
<CHARGE_TYPE>RC</CHARGE_TYPE>
<GUID_TOKEN>053944D794856E3FE0540010E00D30B8</GUID_TOKEN>
<NRC_LINE_ID>0</NRC_LINE_ID>
<TIERID>11</TIERID>
</ROW>
<ROW>
<SET_ID>0</SET_ID>
<SET_DATE>2014-11-09 00:00:00.0</SET_DATE>
<BUNDLE_NAME>Optional test</BUNDLE_NAME>
<BUNDLE_ID>131</BUNDLE_ID>
<BUNDLE_PRICE>30</BUNDLE_PRICE>
<BUNDLE_TYPE>3</BUNDLE_TYPE>
<BUNDLECOMPONENT_LIST>101100</BUNDLECOMPONENT_LIST>
<PACKAGE>10015</PACKAGE>
<PACKAGE_TYPE>5</PACKAGE_TYPE>
<COMPONENT>101103</COMPONENT>
<PRODUCT_DESC>RAI International</PRODUCT_DESC>
<RATE_AMOUNT>20</RATE_AMOUNT>
<DISCOUNT_AMOUNT>0</DISCOUNT_AMOUNT>
<SERVICE_ID>98683812</SERVICE_ID>
<CHARGE_TYPE>RC</CHARGE_TYPE>
<GUID_TOKEN>053944D794856E3FE0540010E00D30B8</GUID_TOKEN>
<NRC_LINE_ID>0</NRC_LINE_ID>
<TIERID>14</TIERID>
</ROW>
</ROWSET>
Hope this helps,
this is full xslt that doesn't shows any compilation error at my end
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:testclass="test.GetOrderQuote" xmlns:ext="http://exslt.org/common" exclude-result-prefixes="testclass">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="ApplicationId"/>
<xsl:template match="/">
<ServiceList>
<xsl:variable name="unique-list" select="//ROWSET/ROW/SERVICE_ID[not(.=following::SERVICE_ID)]"/>
<xsl:for-each select="$unique-list">
<xsl:if test=".!=0">
<Service>
<xsl:variable name="Sid" select="."/>
<ServiceInternalId>
<xsl:value-of select="."/>
</ServiceInternalId>
<BundleList>
<xsl:variable name="unique-bundle" select="//SERVICE_ID/../BUNDLE_ID[not(.=following::BUNDLE_ID)]"/>
<xsl:for-each select="$unique-bundle">
<xsl:variable name="bid" select="."/>
<xsl:if test="count(/ROWSET/ROW/SERVICE_ID[text()=$Sid]/../BUNDLE_ID[text()=$bid])> 0">
<Bundle>
<Bundle_Id>
<xsl:value-of select="$bid"/>
</Bundle_Id>
<Type>
<xsl:value-of select="../BUNDLE_TYPE"/>
</Type>
<Name>
<xsl:value-of select="../BUNDLE_NAME"/>
</Name>
<Price>
<xsl:value-of select="../BUNDLE_PRICE"/>
</Price>
<xsl:variable name="varTierList" select="testclass:getTierByBundleId($bid,$ApplicationId)"/>
<test>
<xsl:value-of select="$varTierList"/>
</test>
<xsl:for-each select="$varTierList/TierList/Tier">
<TierId>
<xsl:value-of select="TierId"/>
</TierId>
</xsl:for-each>
</Bundle>
</xsl:if>
</xsl:for-each>
</BundleList>
</Service>
</xsl:if>
</xsl:for-each>
</ServiceList>
</xsl:template>
</xsl:stylesheet>

Reading values of XML tag in variables inside XSLT

I could not find a similar question anywhere, so thats why posting this new question.
I have an XML that I want to read and convert into SQL using XSLT. The trick part is that the XML elements(i.e. the names) are not known and the XSD for the XML is generated on the fly.
But what is known is certain attributes of the elements.
The XML looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<et:ItemRecordList xmlns:et="urn:org:easetech:easytest:schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:easetech:easytest:schema ItemRecord.xsd ">
<ItemRecord recordId="idvalue0" tableName="item_record">
<itemId columnName="item_id" idColumn="true" length="36" nullable="false">itemId</itemId>
<databaseInstitution columnName="database_institution" length="255" nullable="false">0</databaseInstitution>
<lastModifiedDate columnName="last_modified_date" length="255" nullable="false">2001-12-31T12:00:00</lastModifiedDate>
</ItemRecord>
</et:ItemRecordList>
I want to use this XML and convert it into an INSERT SQL statement using XXSLT.
I created an XSLT like this :
<?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" encoding="UTF-8" />
<xsl:template match="/">
<xsl:for-each select="/*/*">
INSERT INTO
<xsl:value-of select="#tableName" />
(
<xsl:for-each select="/*/*/*">
<xsl:variable name="columnName"><xsl:value-of select="#columnName"/></xsl:variable>
<xsl:choose>
<xsl:when test="#columnName">
<xsl:value-of select="$columnName"/>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:for-each>
)
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
which gives me the output like this :
INSERT INTO item_record (item_id, database_institution, last_modified_date)
But I don't know how to create the value part of the query. The value is the value we get using
<xsl:value-of select="." />
I tried concatenating the values, but unfortunately concat didnt work for me. I also played around with xsl:variable but couldnt make it work. If someone could help me with the XSLT that I can use to create to output like below that would be really appreciated.
INSERT INTO item_record (item_id, database_institution, last_modified_date) values (itemId,0,2001-12-31T12:00:00)
How about:
<xsl:template match="/">
<xsl:for-each select="/*/*">
<xsl:text>INSERT INTO </xsl:text>
<xsl:value-of select="#tableName" />
<xsl:text> (</xsl:text>
<xsl:for-each select="*[#columnName]">
<xsl:value-of select="#columnName"/>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
<xsl:text>) values (</xsl:text>
<xsl:for-each select="*[#columnName]">
<xsl:value-of select="."/>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
The next XSLT will generate the query as wanted
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:variable name="newline" select="'
'" />
<xsl:template match="/">
<xsl:apply-templates select="*/*/#tableName" />
</xsl:template>
<xsl:template match="#tableName">
<xsl:value-of select="concat('INSERT INTO ', ., ' (')" />
<xsl:apply-templates select="parent::*/*/#columnName" />
<xsl:value-of select="') VALUES ('" />
<xsl:apply-templates select="parent::*/*" mode="values" />
<xsl:value-of select="concat(')', $newline)" />
</xsl:template>
<xsl:template match="#columnName">
<xsl:choose>
<xsl:when test="position() = last()">
<xsl:value-of select="." />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(., ', ')" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="values">
<xsl:choose>
<xsl:when test="position() = last()">
<xsl:value-of select="." />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(., ', ')" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

How do I swap ani and dnis values around if direction is 0? If direction is 1 it should be left unchanged

How do I swap ani and dnis values around if direction is 0? If direction is 1 it should be left unchanged.
I have tried with a if command but can get it to work. I hope samebody have a solution for this little issue :)
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="/">
<Call xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Data>
<time_offset>
<xsl:number value="0"/>
</time_offset>
<audio>
<audio_segement>
<channel_id>0</channel_id>
<recording_order>1</recording_order>
<audio_url>
<xsl:value-of select="callinfo/location"/>
</audio_url>
<xsl:apply-templates select="callinfo/startdate"/>
<xsl:apply-templates select="StartTime"/>
<Duration>
<xsl:value-of select="callinfo/duration"/>
</Duration>
</audio_segement>
</audio>
<direction>
<xsl:value-of select="callinfo/direction"/>
</direction>
<ani>
<xsl:value-of select="callinfo/local"/>
</ani>
<dnis>
<xsl:value-of select="callinfo/remote"/>
</dnis>
<unique_identifier>
<xsl:value-of select="callinfo/startdate"/>
</unique_identifier>
<pbx_login_id>
<xsl:value-of select="callinfo/local"/>
</pbx_login_id>
<switch_name>Mobile Data Source</switch_name>
</Data>
</Call>
</xsl:template>
<xsl:template match="callinfo/startdate">
<StartTime>
<xsl:variable name="StartTime">
<xsl:value-of select="concat(substring-before(., ' '), 'T', substring-after(., ' '))"/>
</xsl:variable>
<xsl:variable name="startTimeSize" select = "string-length(.)"/>
<xsl:if test="$startTimeSize = 19">
<xsl:value-of select="$StartTime"/>.00+00:00
</xsl:if>
<xsl:if test="$startTimeSize = 33">
<xsl:value-of select="substring($StartTime,0,24)"/>
<xsl:value-of select="substring($StartTime,28,7)"/>
</xsl:if>
<xsl:if test="$startTimeSize != 33 and $startTimeSize != 19">
<xsl:value-of select="$StartTime"/>
</xsl:if>
</StartTime>
</xsl:template>
</xsl:stylesheet>
Any help will be greatly appreciated.
I am still not sure I understand this. If you just want to change the order in which the elements appear in the output document, without changing their contents, change this part:
<ani>
<xsl:value-of select="callinfo/local"/>
</ani>
<dnis>
<xsl:value-of select="callinfo/remote"/>
</dnis>
to:
<xsl:choose>
<xsl:when test="callinfo/direction=1">
<ani><xsl:value-of select="callinfo/local"/></ani>
<dnis><xsl:value-of select="callinfo/remote"/></dnis>
</xsl:when>
<xsl:otherwise>
<dnis><xsl:value-of select="callinfo/remote"/></dnis>
<ani><xsl:value-of select="callinfo/local"/></ani>
</xsl:otherwise>
</xsl:choose>
Note that in a well-designed XML, the order of siblings should not matter - that's what element names are there for.