XSL Issue

Hi All,
I have the following XML in my source.
<item name='kcStage3ET'><text>text1<break/>text2<break/>text3<break/>fdssa<break
/><break/>s</text></item>

In my XSL I do the following
I do <xsl:template match="item[@name='kcStage3ET']">
<xsl:value-of-select"."/>
</xsl:template>

This returns me the value text1text2text3 in the final result.I would like to see that whenever there is a <break/> in the source as above,the <break/> tag should be inserted as is.In short my output after XSLT should result in text1<break/>text2<break/>text3,break/>.

Only if the break tags occur will my application import the final XML.
Is there like an option in value-of-select to say that select the literal value of the node?
I am not sure.
I would appreciate if anybody could help me as to how to accomplish this in XSL.
Thanks in advance,
Sreeni.
[1025 byte] By [sreeni_78] at [2007-11-18 17:27:08]
# 1 Re: XSL Issue
Originally posted by sreeni_78
Is there like an option in value-of-select to say that select the literal value of the node?

No, xsl:value-of converts nodesets to text output by recursivly outputing the text contents of each node.

The trick is of course not to use value-of.
Something like this should do.

<xsl:template match="item[@name='kcStage3ET']">
<xsl:apply-templates select"text()|break"/>
</xsl:template>

<xsl:template match="break">
<xsl:copy-of select="."/>
</xsl:template>
khp at 2007-11-10 3:28:20 >
# 2 Re: XSL Issue
Thanks for the reply.I tried the solution you had given me.I still get the same result,that is text1text2..so on.I want to put out text1 <break/>text2<break/>text3.

Any ideas?

I would really appreciate your help.

Thanks,
Sreeni.
sreeni_78 at 2007-11-10 3:29:20 >
# 3 Re: XSL Issue
That's rather strange, if you replaced your template, with the two templates, I posted above, you should not get any output at all, because I don't select the <text> node that wraps all the text and the breaks (an oversight on my part).
If you replace it with this it should work.

<xsl:template match="item[@name='kcStage3ET']">
<xsl:apply-templates select="text/text()|text/break"/>
</xsl:template>

<xsl:template match="break">
<xsl:copy-of select="."/>
</xsl:template>

If you can't get this to work, please post your entire stylesheet and xml file.
khp at 2007-11-10 3:30:18 >
# 4 Re: XSL Issue
Thanks for your email.This one didn't work either.I am sending the XML and Stylesheet.The XSL file runs for a few pages.
I look forward to hear from you.If you need more details let me know.
Thank You,
Sreeni.

This is is my source XML:

<?xml version='1.0' encoding='utf-8'?>

<database xmlns='http://www.lotus.com/dxl' version='6.0'

maintenanceversion='3.0'
replicaid='05256E3E007267EA'

path='CN=Scorpio/OU=SRV/O=MilkyWay/C=US!!Dev\Prototype.nsf'
title='Prototype'>
<databaseinfo

dbid='05256E3E007267EA' odsversion='43' diskspace='829440' percentused='76.2037037037037'


numberofdocuments='2'><datamodified><datetime>20040224T094444,03-05</datetime></datamodified>

<designmodified
><datetime>20040224T100818,83-05</datetime></designmodified></databaseinfo>

<document form='frmJpDef'>
<noteinfo noteid='8fa' unid='CEB50E80C02722F205256E440050C6DB'

sequence='1'>
<created><datetime>20040224T094217,87-05</datetime></created>
<modified><datetime>20040224T094444,03-05</datetime></modified>
<revised><datetime>20040224T094444,00-05</datetime></revised>
<lastaccessed><datetime>20040224T094444,03-05</datetime></lastaccessed>
<addedtofile><datetime>20040224T094444,03-05</datetime></addedtofile></noteinfo>
<updatedby><name>CN=Sreenivasan Rajagopalan/OU=SB/O=CroweChizek/C=US</name></updatedby>
<item

name='careerJobPrfET'><text>Manager</text></item>
<item

name='sbuCodeMT'><text>080</text></item>
<item name='sbuLngNameMT'><text>Enterprise

Solutions</text></item>
<item name='careerPathET'><text>Service Delivery</text></item>
<item

name='jpVersionET'><text>101</text></item>
<item name='jobSummaryET'><text>This is a sample

of summary text.</text></item>
<item name='rspnbPrmryDescr01MT'><text>Prim Responsibility
#1</text></item>
<item name='rspnbPrmryDescr02MT'><text>Prim Responsibility
#2</text></item>
<item name='rspnbOtherDescr01MT'><text>Other resp #1</text></item>
<item name='skillDescr01MT'><text>Tech Skil #1</text></item>
<item name='kcStage1ET'><text>text 1<break/><break/>text 2</text></item>
<item name='kcStage2ET'><text/></item>
<item name='kcStage3ET'><text>sdfjjfsd<break/><break/><break/>fdssa<break
/><break/>s</text></item>
<item name='kcStage4ET'><text/></item>
<item name='educationCertET'><text>cert 1<break/>cert 2<break/></text></item>
<item

name='jpKeyCT'><text>080:Service Delivery:Manager</text></item></document></database>

----End of XML----------------
-------------------------
XSL File:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:dxl="http://www.lotus.com/dxl">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="dxl:datamodified">
<xsl:apply-templates select="datetime"/>
<xsl:text></xsl:text>
</xsl:template>
<xsl:template match="dxl:designmodified">
<xsl:apply-templates select="datetime"/>
<xsl:text></xsl:text>
</xsl:template>

<xsl:template match="dxl:document">

<database xmlns='http://www.lotus.com/dxl' version='6.0'>

some XML is here with apply templates select commands.



</database>
</xsl:template>

<xsl:template match="dxl:item[@name='jpKeyCT']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='jpVersionET']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='careerJobPrfET']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='sbuLngNameMT']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='careerPathET']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='jobSummaryET']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='rspnbPrmryDescr01MT']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='rspnbOtherDescr01MT']">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="dxl:item[@name='skillDescr01MT']">
<xsl:value-of select="."/>
</xsl:template>

<xsl:template match="item[@name='kcStage1ET']">
<xsl:apply-templates select="text/text()|text/break"/>
</xsl:template>

<xsl:template match="break">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
sreeni_78 at 2007-11-10 3:31:23 >
# 5 Re: XSL Issue
Your xml file uses the namespace "http://www.lotus.com/dxl" you need to match this in the XSL file.
In the xsl file you have already declared this to use the dxl prefix. So the item and break templates should look like this

<xsl:template match="dxl:item[@name='kcStage1ET']">
<xsl:apply-templates select="dxl:text/text()|dxl:text/dxl:break"/>
</xsl:template>

<xsl:template match="dxl:break">
<xsl:copy-of select="."/>
</xsl:template>
khp at 2007-11-10 3:32:25 >
# 6 Re: XSL Issue
Thanks a lot.That worked.Thanks for pointing me towards the namespace,I had it right in the other templates but missed it in this particular one.
I really appreciate your help.
Sreeni.
sreeni_78 at 2007-11-10 3:33:20 >