miss something about xslt

N

Ndeye

Hi all
I have this xml file (generated from Lotus Domino 6) and would like to
transform it to a simpler one by extracting only data between the gif
tag (I cut the gif data to reduce the file here);
I wrote an xls to do it to transform the xml file.
What am I doing wrong ? because what I get is all the data in the xml
file instead of my expected output file :eek:((

Need your help
Ndeye, a new "xslter"

*my xml input file :
<?xml version="1.0" ?>
<!DOCTYPE document (View Source for full doctype...)>
- <document xmlns="http://www.lotus.com/dxl" version="6.5"
replicaid="C1256DC700510DFF" form="Person" response="false"
conflict="false">
+ <noteinfo noteid="356e" unid="60C4C68E08994352C1256E00003026AB"
sequence="2">
+ <updatedby>
+ <item name="full_name" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
- <item name="Picture" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
- <richtext>
- <pardef id="1" leftmargin="1%" rightmargin="99%" keeptogether="true"
align="left" linespacing="1" spacebefore="1" spaceafter="1"
newpage="false" list="none" readingorder="lefttoright">
- <code event="hidewhen">
<formula>(!@IsDocBeingEdited &
NoPhotoThanks="NoPhoto")|(@IsDocBeingEdited & isweb)</formula>
</code>
</pardef>
- <par def="1">
- <picture width="182px" height="136px" align="baseline">
<gif>R0lGODlhtgCIAOcAAP///4CAgIiIiGhoYFBQSKioiCgoKCAgGBAICCgoIPD4+Hh4eAAAAKCggHh4
cIiIgCAgIDAwKBgQEHBwaJiYeICAcPDw8JiYgJCQiAgICHBwcGBgWJCQkDAoIICAeBgYEFBQQEhQ</gif>
</picture>
</par>
<par />
</richtext>
</item>
+ <item name="jobdescrip_me" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
+ <item name="Phone_Me" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
+ <item name="EMail_me" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
+ <item name="ShowHasPic" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
+ <item name="$Revisions" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
</document>


*my xsl input file :
<?xml version="1.0" encoding="UTf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml" version="1.0" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="gif"/>
</xsl:template>
<xsl:template match="gif">
<gifdata>
<xsl:value-of select="."/>
</gifdata>
</xsl:template>
</xsl:stylesheet>

*my expected xml ouput :
<?xml version="1.0" encoding="UTf-8"?>
<gifdata>
R0lGODlhtgCIAOcAAP///4CAgIiIiGhoYFBQSKioiCgoKCAgGBAICCgoIPD4+Hh4eAAAAKCggHh4
cIiIgCAgIDAwKBgQEHBwaJiYeICAcPDw8JiYgJCQiAgICHBwcGBgWJCQkDAoIICAeBgYEFBQQEhQ
</gifdata>
 
D

Dimitre Novatchev

xsl:value-of is an xslt instruction, which produces the string value of a
node -- this is the concatenation (in document order) of all of its text
node descendents.

And this is what you get.

What you really wanted was to use the:

xsl:copy-of

instruction.



Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html


Ndeye said:
Hi all
I have this xml file (generated from Lotus Domino 6) and would like to
transform it to a simpler one by extracting only data between the gif
tag (I cut the gif data to reduce the file here);
I wrote an xls to do it to transform the xml file.
What am I doing wrong ? because what I get is all the data in the xml
file instead of my expected output file :eek:((

Need your help
Ndeye, a new "xslter"

*my xml input file :
<?xml version="1.0" ?>
<!DOCTYPE document (View Source for full doctype...)>
- <document xmlns="http://www.lotus.com/dxl" version="6.5"
replicaid="C1256DC700510DFF" form="Person" response="false"
conflict="false">
+ <noteinfo noteid="356e" unid="60C4C68E08994352C1256E00003026AB"
sequence="2">
+ <updatedby>
+ <item name="full_name" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
- <item name="Picture" sign="false" seal="false" sealed="false"
authors="false" names="false" readers="false" placeholder="false">
- <richtext>
- <pardef id="1" leftmargin="1%" rightmargin="99%" keeptogether="true"
align="left" linespacing="1" spacebefore="1" spaceafter="1"
newpage="false" list="none" readingorder="lefttoright">
- <code event="hidewhen">
<formula>(!@IsDocBeingEdited &
NoPhotoThanks="NoPhoto")|(@IsDocBeingEdited & isweb)</formula>
</code>
</pardef>
- <par def="1">
- <picture width="182px" height="136px" align="baseline">
cIiIgCAgIDAwKBgQEHBwaJiYeICAcPDw8JiYgJCQiAgICHBwcGBgWJCQkDAoIICAeBgYEFBQQEhQ
 
P

Patrick TJ McPhee

% What am I doing wrong ? because what I get is all the data in the xml
% file instead of my expected output file :eek:((

Is it really this XSLT that gives you all the data? You haven't given
a complete sample file, so I'm not going to bother trying to run it,
but I'd expect the XSLT you gave to give no output at all.

% <xsl:template match="/">
% <xsl:apply-templates select="gif"/>
% </xsl:template>

This apply-templates will select all the `gif' elements that appear
as children of the root. Since there are none, it should match nothing.

If you really left out this template, and you got all the text in the
document in addition to your new gifdata element, the problem is that,
by default, XSLT adds all text elements to the result tree. You need
to either fix the select expression above (select='document/picture/gif'),
or add a template to handle text elements

<xsl:template match='text()'/>
 
D

Dimitre Novatchev

Of course, Patrick is right.

Ndeye,
I didn't bother look into your xml document, as it was absolutely
unreadable. In the future at least try to provide well-indented and readable
xml documents, not a copy of a collapsible/expandable outline, in which some
nodes are collapsed and some are expanded. Also, the "+" and "-" signs
contribute to the confusion.

If your source was *really* this:
% <xsl:template match="/">
% <xsl:apply-templates select="gif"/>
% </xsl:template>

then no output should be produced when applied on the provided xml document.

Therefore, most probably you're not showing the real xml document and/or the
real xslt code.



Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,016
Latest member
TatianaCha

Latest Threads

Top