miss something about xslt

Discussion in 'XML' started by Ndeye, Dec 18, 2003.

  1. Ndeye

    Ndeye Guest

    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>
     
    Ndeye, Dec 18, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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+Hh4eAAAAKC
    ggHh4
    >

    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>
     
    Dimitre Novatchev, Dec 18, 2003
    #2
    1. Advertising

  3. In article <>,
    Ndeye <> wrote:

    % 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()'/>

    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Dec 18, 2003
    #3
  4. 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


    "Patrick TJ McPhee" <> wrote in message
    news:brsojt$4rf$...
    > In article <>,
    > Ndeye <> wrote:
    >
    > % 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()'/>
    >
    > --
    >
    > Patrick TJ McPhee
    > East York Canada
    >
     
    Dimitre Novatchev, Dec 18, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. youngeagle

    I miss frames!

    youngeagle, Aug 24, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    655
    Vidar Petursson
    Oct 23, 2004
  2. Wayne Wengert

    What Did I Miss?

    Wayne Wengert, May 25, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    441
    Wayne Wengert
    May 25, 2005
  3. Paul Watt

    God I miss tables-help needed!

    Paul Watt, Apr 4, 2006, in forum: HTML
    Replies:
    53
    Views:
    1,204
    Paul Ding
    Apr 8, 2006
  4. JJ
    Replies:
    2
    Views:
    364
  5. Rasmus Johansen
    Replies:
    4
    Views:
    385
    Victor Bazarov
    Oct 18, 2007
Loading...

Share This Page