RE: [xsl] Unanticipated Results from text()

Subject: RE: [xsl] Unanticipated Results from text()
From: "Signature House" <systems@xxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Feb 2007 12:02:12 -0500
Michael

Thanks for the response, but I'm afraid I'm even more confused now then before.
Loss of whitespace isn't what concerns me, it's the loss of the non-whitespace that has me puzzled.

No matter how many line-breaks are in the XML, or where they're placed, in IE the "normalize-space(text())" picks up the "B2" text
as I expected. But FileMaker/Xalan/Xerces won't pick up the "B2" text if a line-break appears between the <BBB><CCC>. I just tried
the other white-space characters (blank and tab) and the same thing happened. No white-space between the <BBB><CCC>,
FM//Xalan/Xerces get the "B2", any white-space between <BBB><CCC>, FM//Xalan/Xerces doesn't get the "B2" text.

Thanks

Mike McBee
Signature House
systems@xxxxxxxxxxxxxxxxxx
www.signaturehouse.net
304-842-3386

-> -----Original Message-----
-> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
-> Sent: Friday, February 23, 2007 12:57 PM
-> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
-> Subject: RE: [xsl] Unanticipated Results from text()
->
->
-> The Microsoft XML parser strips whitespace text nodes by default. (Indeed,
-> when running in IE from an xml-stylesheet PI it's impossible to prevent
-> this.) This runs against the spirit of the specs, and leads to this kind of
-> interoperability problem.
->
-> If you actually want the whitespace stripped, you can get this done in a
-> portable way by using <xsl:strip-space elements="*"/> in your stylesheet.
->
-> If you don't want the whitespace stripped, for example if you have
->
-> <p>My name is <first>Michael</first> <last>Kay</last></p>
->
-> in your source document, then you're hosed: you have to write Javascript
-> that politely asks Microsoft to give you all your XML, not just the bits it
-> thought you might find interesting.
->
-> Michael Kay
-> http://www.saxonica.com/
->
->
-> > -----Original Message-----
-> > From: Signature House [mailto:systems@xxxxxxxxxxxxxxxxxx]
-> > Sent: 23 February 2007 17:35
-> > To: XSL List
-> > Subject: [xsl] Unanticipated Results from text()
-> >
-> > Hi
-> >
-> > I'm working on a project involving an XML import into the
-> > FileMaker DB package. I'm using Internet Explorer to do
-> > quickie proofing on my stylesheets before using them in FM
-> > since FM is a bit of a kludge.
-> >
-> > I got one bit working the way I wanted in IE, but got a
-> > different result when I moved it into FM.
-> >
-> > Using the IE STYLESHEET and XML INPUT 1 below, I got IE
-> > RESULTS FROM BOTH INPUTS vs FM RESULTS FROM INPUT 1. The
-> > "normalize-space(text())" picked up the B2 text in IE but
-> > didn't in FM.
-> >
-> > I ran about a dozen different versions of the XML input,
-> > removing 1 or more line breaks from different places. IE
-> > always picked up the B2 text; sometimes FM did, sometimes it
-> > didn't (see at FM RESULTS FROM INPUT 2 for one where FM did work).
-> >
-> > Empirically, if <BBB><CCC> were on the same line, IE & FM
-> > returned the same results; if <BBB><CCC> were on separate
-> > lines, the results were different.
-> >
-> > I'm working on a PC running XP SP2, IE 6 SP2 and FM 8.03. FM
-> > says they're using an Xerces-based XML parser and an
-> > Xalan-based XSLT processor (Xerces-C 1.6.0, Xalan-C 1.3.0).
-> > My stylesheets use the same XSLT, but for FM I have to remove
-> > the HTML and add a bunch of required metadata. It's longish
-> > so I didn't include it but I can if someone needs to see it.
-> > The line breaks are the standard Windows hex 0D 0A pair.
-> >
-> > Does anybody have any suggestions as to what is going on?
-> > - Is the placement of the B2 text valid XML?
-> > - Is this a difference between IE & Xalan?
-> > - What results should I expect - B2 or not B2? (Gee, I should
-> > have used 2B as the sample!)
-> >
-> > Thanks in advance
-> >
-> > Mike McBee
-> > Signature House
-> > systems@xxxxxxxxxxxxxxxxxx
-> > www.signaturehouse.net
-> > 304-842-3386
-> >
-> >
-> > IE STYLESHEET
-> > <?xml version="1.0"?>
-> > <?xml-stylesheet type="text/xsl" href="List Nodes -
-> > HTML.xsl"?> <xsl:template match="/">
-> >   <table>
-> >     <tr><td>Name</td><td>Text</td><td>Period</td></tr>
-> >     <xsl:for-each select="//*">
-> >       <tr>
-> >         <td><xsl:value-of select="name(.)"/></td>
-> >         <td><xsl:value-of select="normalize-space(text())"/></td>
-> >         <td><xsl:value-of select="normalize-space(.)"/></td>
-> >     </tr>
-> >     </xsl:for-each>
-> >   </table>
-> > </xsl:template>
-> >
-> >
-> > XML INPUT 1
-> > <?xml version="1.0"?>
-> > <?xml-stylesheet?>
-> > <AAA>
-> > <BBB>
-> > <CCC>
-> > C1
-> > </CCC>
-> > B2
-> > </BBB>
-> > </AAA>
-> >
-> >
-> > XML INPUT 2
-> > <?xml version="1.0"?>
-> > <?xml-stylesheet?>
-> > <AAA><BBB><CCC>C1</CCC>B2</BBB></AAA>
-> >
-> >
-> > IE RESULTS FROM BOTH INPUTS
-> > Name  Text  Period
-> > AAA         C1 B2
-> > BBB   B2    C1 B2
-> > CCC   C1    C1
-> >
-> >
-> > FM RESULTS FROM INPUT 1
-> > Name  Text  Period
-> > AAA         C1 B2
-> > BBB         C1 B2
-> > CCC   C1    C1
-> >
-> >
-> > FM RESULTS FROM INPUT 2
-> > Name  Text  Period
-> > AAA         C1 B2
-> > BBB   B2    C1 B2
-> > CCC   C1    C1
-> >
-> >
-> >
-> >
-> >
->
->
->
->
->

Current Thread