Modifying Source Data from XSLT

Discussion in 'XML' started by Jamie Jackson, Jun 8, 2006.

  1. [Warning, XSLT noob.]

    In the XML source I'm working with, some node values that should be
    identical, vary slightly from value to value. The differences are in
    whitespace (some have a carriage return mid-string).

    Ideally, I'd like to normalize-space() all of the values of the
    underlying data, so that I later use and reuse the cleaned data
    throughout the rest of the transformation (so I could properly use
    distinct-values() on that list, etc.).

    Is there a way to modify the underlying data, as opposed to having to
    clean it each time you come to it?

    Thanks,
    Jamie
    Jamie Jackson, Jun 8, 2006
    #1
    1. Advertising

  2. Jamie Jackson wrote:
    > Is there a way to modify the underlying data, as opposed to having to
    > clean it each time you come to it?


    You can't alter the source document -- expect by taking a two-pass
    approach, one pass to create the altered source and then a second pass
    to style from that. The two passes can be done in a single stylesheet,
    with some work, if you're either using XSLT2 or are willing to use the
    EXSLT node-set() function -- build the altered tree in a variable, then
    style from that -- but of course this doubles your memory use and means
    touching everything twice, so it may not be a net win.
    Joe Kesselman, Jun 8, 2006
    #2
    1. Advertising

  3. Joe Kesselman wrote:
    > Jamie Jackson wrote:
    > > Is there a way to modify the underlying data, as opposed to having to
    > > clean it each time you come to it?

    >
    > You can't alter the source document -- expect by taking a two-pass
    > approach, one pass to create the altered source and then a second pass
    > to style from that. The two passes can be done in a single stylesheet,
    > with some work, if you're either using XSLT2 or are willing to use the
    > EXSLT node-set() function -- build the altered tree in a variable, then
    > style from that -- but of course this doubles your memory use and means
    > touching everything twice, so it may not be a net win.


    Okay, it's probably not worth the trouble, but good to know, thanks.

    I've come up with a decent, simple workaround for my current issue, so
    I'm set for today.

    Thanks,
    Jamie
    Jamie Jackson, Jun 8, 2006
    #3
    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. Prashanth  Ellina

    XSLT modifying an xml dom tree?

    Prashanth Ellina, Aug 1, 2005, in forum: XML
    Replies:
    6
    Views:
    469
    Prashanth Ellina
    Aug 2, 2005
  2. Paradox

    PyDoc modifying the source.

    Paradox, Dec 7, 2003, in forum: Python
    Replies:
    1
    Views:
    319
    Paradox
    Dec 8, 2003
  3. Jan Gregor
    Replies:
    7
    Views:
    303
    Jan Gregor
    Nov 8, 2005
  4. Author Tarun Tyagi
    Replies:
    0
    Views:
    685
    Author Tarun Tyagi
    Dec 29, 2004
  5. Allan Ebdrup
    Replies:
    2
    Views:
    455
    Allan Ebdrup
    Oct 6, 2006
Loading...

Share This Page