Weirdness:<xsl:value-of> output appears twice
Added by Anonymous about 19 years ago
Legacy ID: #3350829 Legacy Poster: Nick Sayer (nsayer)
We've been using saxon-B 8.3 (the saxon8.jar and saxon8-xpath.jar) with Java 1.5 for a while now with version="1.0" stylesheets. When we try to switch them to version="2.0" and make NO other changes, most of the <xsl:value-of> output shows up twice. As in, Dear Fred Fred, We're glad you're happy with your gizmo gizmo that we shipped you last Thursday Thursday. It's a little bit disconcerting disconcerting. We tried upgrading the two jars to 8.5.1, but the behavior persists. The really disturbing thing is that if I make up a very short program that just reads in the template and data and does the transform, it doesn't fail. But in the full application, it does. Of course, if I set the stylesheet version back to 1.0, it also stops failing. I know this isn't really enough information to go on, but I am hoping that someone recognizes the symptom and we can cut to the chase.
Replies (5)
Please register to reply
RE: Weirdness:<xsl:value-of> output appears twice - Added by Anonymous about 19 years ago
Legacy ID: #3350838 Legacy Poster: Nick Sayer (nsayer)
One more datapoint... We are setting an OutputURIResolver, but in the stylesheet under consideration, we're not sending anything to an alternate output document (the capability is for future use).
RE: Weirdness:<xsl:value-of> output appears t - Added by Anonymous about 19 years ago
Legacy ID: #3350859 Legacy Poster: Michael Kay (mhkay)
It's hard to debug your code without seeing it, so I can only speculate as to possible causes. When a stylesheet specifies version="1.0", <xsl:value-of> outputs the value of the first node in the supplied node-set. When it specifies version="2.0", it outputs the values of all the nodes, space-separated. So you would see this effect, for example, if the stylesheet contains the code: <xsl:value-of select="name | name/text()"/> In general, if your stylesheet exhibits this problem, you can probably fix it by changing <xsl:value-of select="EXPR"/> to <xsl:value-of select="(EXPR)[1]"/> In the above case, of course, the fix is simpler. This isn't the place to discuss whether or not the spec is doing the "right thing": but I'm pretty sure that Saxon is implementing the spec correctly. Michael Kay
RE: Weirdness:<xsl:value-of> output appears twice - Added by Anonymous about 19 years ago
Legacy ID: #3352082 Legacy Poster: Nick Sayer (nsayer)
I hear what you're saying, but the problem is that if I take the exact same XML document and stylesheet (with version="2.0") and run it in a "hello world" style transformer program, it gives the expected output. In our application, it fails. Our application is effectively a "mail merge" system. The XML document contains order information and the stylesheet generates an e-mail to be sent to the customer. Some customers want text-only e-mail, some prefer HTML. When they don't give us their preference, we send a multi-part alternative MIME version. This doubling behavior ONLY seems to happen when the multipart version is sent, and then only with the HTML variant. If the HTML variant is sent alone, it's fine. If the stylesheet version is 1.0, it's fine. There are a bunch of worker threads in the real application, but they don't parallelize generating the text and html variants of a multipart message. And in any event, everything is fine if the stylesheet version is 1.0.
RE: Weirdness:<xsl:value-of> output appears t - Added by Anonymous about 19 years ago
Legacy ID: #3352130 Legacy Poster: Michael Kay (mhkay)
I'm happy to help you find the bug if you make the code available in a form I can run, but without that, I'm sorry, there's not much I can do.
RE: Weirdness:<xsl:value-of> output appears twice - Added by Anonymous about 19 years ago
Legacy ID: #3361467 Legacy Poster: Nick Sayer (nsayer)
Found it. The error was not in the XSLT layer, but in the generation of the XML source document. It was generating some nodes more than once under certain circumstances, which accounts precisely for the difference in behavior. Your hint about the difference between 1.0 and 2.0 pointed me in the right direction once I thought about it long enough. Thanks for the clue and sorry to waste your time. :)
Please register to reply