RE: Is this a bug?
Larry Trammell <[email protected]> Thu, 3 Dec 2015 11:14:48 -0800
| Newsgroups | gmane.text.xml.xalan.java.user |
|---|---|
| Message-ID | <34FBDC3809811D4299E07FABC487CB67D926A5@mailserver.local.mstarlabs.com> |
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01D12DFE.E06F0A00 Content-Type: text/plain Maksim, I'm far from expert at this stuff. But if you expected the translation to process more than one matched item, shouldn't that template be using <xsl:apply-templates> somewhere? If I read the example template correctly, it will find the first match to '*', copy that item to output, and then it is done. Which seems to be what happened... Java looks like an innocent bystander. If you can check this example with any other XSLT processor, I would expect the same results. A word of warning: this mailing list tends to be the territory of some serious world class experts on Xalan, but a little grumpy about helping with XSLT coding issues. If that is all this turns out to be, you probably want to take further questions elsewhere. Larry _____ From: [email protected] [mailto:[email protected]] Sent: Wednesday, December 02, 2015 6:13 AM To: [email protected] Subject: Is this a bug? Hello! I tried to transform the attached XML with the attached XSL. This is the Java source: final TransformerFactory trf = TransformerFactory.newInstance(); final Transformer tr = trf.newTransformer(new StreamSource(_formxsl.getInputStream())); tr.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); tr.setOutputProperty(OutputKeys.INDENT, "no"); StringWriter writer = new StringWriter(); final StreamResult result = new StreamResult(writer); tr.transform(new StreamSource(_formxml.getInputStream()), result); writer.flush(); writer.toString(); _formxsl and _formxml are both Resource, they are attached to this message. The transform result by http://xslt.online-toolz.com/tools/xslt-transformation.php <http://xslt.online-toolz.com/tools/xslt-transformation.php> (AND http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog <http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatal og> &xsltfile=cdcatalog) looks like this: <?xml version="1.0"?> <ros:relobjects xmlns:ros="urn://x-artefacts-vs-it-ru/p321/schema/relobjects/1.0" xmlns:bo="urn://x-artefacts-it-ru/p321/Application/1.0" xmlns:fo="urn://x-artefacts-it-ru/p321/Step2Form/1.0" xmlns:ct="urn://x-artefacts-it-ru/p321/ComplexTypes/1.0" xmlns:st="urn://x-artefacts-it-ru/p321/SimpleTypes/1.0" xmlns:da="urn://x-artefacts-it-ru/dob/document-attachment/1.1"><ros:RO type="VEHICLE_OWNER_DRIVER" id="5672f6f9-176e-42cb-ae76-de1973a77bde"> <ros:BO role="VEHICLE"/> <ros:BO role="OWNER"/> <ros:BO role="DRIVER">76bd59e9-166c-4a22-9e6b-b196849be358</ros:BO> <ros:BO role="DRIVER">5fb19f85-0617-4782-9a4f-fdc2a60c5e64</ros:BO> <ros:BO role="DRIVER">f39bafdc-7fab-472d-965e-398e87a1472a</ros:BO> </ros:RO></ros:relobjects> But the result produced by Java is merely this: <ros:relobjects xmlns:ros="urn://x-artefacts-vs-it-ru/p321/schema/relobjects/1.0" xmlns:da="urn://x-artefacts-it-ru/dob/document-attachment/1.1" xmlns:st="urn://x-artefacts-it-ru/p321/SimpleTypes/1.0" xmlns:ct="urn://x-artefacts-it-ru/p321/ComplexTypes/1.0" xmlns:fo="urn://x-artefacts-it-ru/p321/Step2Form/1.0" xmlns:bo="urn://x-artefacts-it-ru/p321/Application/1.0"><ros:RO type="VEHICLE_OWNER_DRIVER" id="5672f6f9-176e-42cb-ae76-de1973a77bde"/></ros:relobjects> - i.e. no BO elements at all. Why does this happen? Is there some mistake or undefined behavior in my stylesheet? Thank you! Maksim ------_=_NextPart_001_01D12DFE.E06F0A00 Content-Type: text/html Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"> <META name=3DGENERATOR content=3D"MSHTML 10.00.9200.17556"></HEAD> <BODY> <DIV dir=3Dltr align=3Dleft><SPAN class=3D719225118-03122015><FONT = size=3D2=20 face=3DArial>Maksim, I'm far from expert at this stuff. But if you = expected=20 the translation to process more than one matched item, shouldn't = that=20 template be using <xsl:apply-templates> somewhere? = If I=20 read the example template correctly, it will find the = first match=20 to '*', copy that item to output, and then it is = done. Which=20 seems to be what happened... Java looks like an innocent = bystander.=20 </FONT></SPAN></DIV> <DIV dir=3Dltr align=3Dleft><SPAN class=3D719225118-03122015><FONT = size=3D2=20 face=3DArial></FONT></SPAN> </DIV> <DIV dir=3Dltr align=3Dleft><SPAN class=3D719225118-03122015><FONT = size=3D2=20 face=3DArial>If you can check this example with any other XSLT = processor, I would=20 expect the same results.</FONT></SPAN></DIV> <DIV dir=3Dltr align=3Dleft><SPAN class=3D719225118-03122015><FONT = size=3D2=20 face=3DArial></FONT></SPAN> </DIV> <DIV dir=3Dltr align=3Dleft><SPAN class=3D719225118-03122015><FONT = size=3D2 face=3DArial>A=20 word of warning: this mailing list tends to be the territory of some = serious=20 world class experts on Xalan, but a little grumpy about helping = with XSLT=20 coding issues. If that is all this turns out to be, you=20 probably want to take further questions=20 elsewhere. </FONT></SPAN></DIV> <DIV dir=3Dltr align=3Dleft><SPAN class=3D719225118-03122015><FONT = size=3D2=20 face=3DArial></FONT></SPAN> </DIV> <DIV dir=3Dltr align=3Dleft><SPAN class=3D719225118-03122015><FONT = size=3D2=20 face=3DArial>Larry </FONT></SPAN></DIV><BR> <DIV lang=3Den-us class=3DOutlookMessageHeader dir=3Dltr align=3Dleft> <HR tabIndex=3D-1> <FONT size=3D2 face=3DTahoma><B>From:</B> [email protected]=20 [mailto:[email protected]] <BR><B>Sent:</B> Wednesday, December 02, = 2015 6:13=20 AM<BR><B>To:</B> [email protected]<BR><B>Subject:</B> Is = this a=20 bug?<BR></FONT><BR></DIV> <DIV></DIV> <DIV dir=3Dltr>Hello! <DIV>I tried to transform the attached XML with the attached XSL. <DIV>This is the Java source:</DIV> <DIV><PRE style=3D"FONT-FAMILY: 'Courier New'; COLOR: rgb(0,0,0)"><SPAN = style=3D"FONT-WEIGHT: bold; COLOR: rgb(0,0,128)">final = </SPAN>TransformerFactory trf =3D TransformerFactory.<SPAN = style=3D"FONT-STYLE: italic">newInstance</SPAN>();<BR><SPAN = style=3D"FONT-WEIGHT: bold; COLOR: rgb(0,0,128)">final = </SPAN>Transformer tr =3D trf.newTransformer(<SPAN = style=3D"FONT-WEIGHT: bold; COLOR: rgb(0,0,128)">new = </SPAN>StreamSource(<SPAN style=3D"FONT-WEIGHT: bold; COLOR: = rgb(102,14,122)">_formxsl</SPAN>.getInputStream()));<BR>tr.setOutputProp= erty(OutputKeys.<SPAN style=3D"FONT-WEIGHT: bold; COLOR: = rgb(102,14,122); FONT-STYLE: italic">OMIT_XML_DECLARATION</SPAN>, <SPAN = style=3D"FONT-WEIGHT: bold; COLOR: = rgb(0,128,0)">"yes"</SPAN>);<BR>tr.setOutputProperty(OutputKeys.<SPAN = style=3D"FONT-WEIGHT: bold; COLOR: rgb(102,14,122); FONT-STYLE: = italic">INDENT</SPAN>, <SPAN style=3D"FONT-WEIGHT: bold; COLOR: = rgb(0,128,0)">"no"</SPAN>);<BR><BR><BR>StringWriter writer =3D <SPAN = style=3D"FONT-WEIGHT: bold; COLOR: rgb(0,0,128)">new = </SPAN>StringWriter();<BR><SPAN style=3D"FONT-WEIGHT: bold; COLOR: = rgb(0,0,128)">final </SPAN>StreamResult result =3D <SPAN = style=3D"FONT-WEIGHT: bold; COLOR: rgb(0,0,128)">new = </SPAN>StreamResult(writer);<BR>tr.transform(<SPAN = style=3D"FONT-WEIGHT: bold; COLOR: rgb(0,0,128)">new = </SPAN>StreamSource(<SPAN style=3D"FONT-WEIGHT: bold; COLOR: = rgb(102,14,122)">_formxml</SPAN>.getInputStream()), = result);<BR>writer.flush();<BR>writer.toString();<BR></PRE></DIV></DIV> <DIV><BR></DIV> <DIV>_formxsl and _formxml are both Resource, they are attached to this = message.</DIV> <DIV><BR></DIV> <DIV>The transform result by <A=20 href=3D"http://xslt.online-toolz.com/tools/xslt-transformation.php">http= ://xslt.online-toolz.com/tools/xslt-transformation.php</A>=20 (<B>AND</B> <A=20 href=3D"http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=3Dcdcatalog&= ;xsltfile=3Dcdcatalog">http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=3D= cdcatalog&xsltfile=3Dcdcatalog</A>)=20 looks like this:</DIV> <DIV><BR></DIV> <DIV> <DIV><?xml version=3D"1.0"?></DIV> <DIV><ros:relobjects=20 xmlns:ros=3D"urn://x-artefacts-vs-it-ru/p321/schema/relobjects/1.0"=20 xmlns:bo=3D"urn://x-artefacts-it-ru/p321/Application/1.0"=20 xmlns:fo=3D"urn://x-artefacts-it-ru/p321/Step2Form/1.0"=20 xmlns:ct=3D"urn://x-artefacts-it-ru/p321/ComplexTypes/1.0"=20 xmlns:st=3D"urn://x-artefacts-it-ru/p321/SimpleTypes/1.0"=20 xmlns:da=3D"urn://x-artefacts-it-ru/dob/document-attachment/1.1"><= ros:RO=20 type=3D"VEHICLE_OWNER_DRIVER" = id=3D"5672f6f9-176e-42cb-ae76-de1973a77bde"></DIV> <DIV><ros:BO role=3D"VEHICLE"/></DIV> <DIV><ros:BO role=3D"OWNER"/></DIV> <DIV><ros:BO=20 role=3D"DRIVER">76bd59e9-166c-4a22-9e6b-b196849be358</ros:BO></= DIV> <DIV><ros:BO=20 role=3D"DRIVER">5fb19f85-0617-4782-9a4f-fdc2a60c5e64</ros:BO></= DIV> <DIV><ros:BO=20 role=3D"DRIVER">f39bafdc-7fab-472d-965e-398e87a1472a</ros:BO></= DIV> <DIV></ros:RO></ros:relobjects></DIV></DIV> <DIV><BR></DIV> <DIV>But the result produced by Java is merely this:</DIV> <DIV><BR></DIV> <DIV><ros:relobjects=20 xmlns:ros=3D"urn://x-artefacts-vs-it-ru/p321/schema/relobjects/1.0"=20 xmlns:da=3D"urn://x-artefacts-it-ru/dob/document-attachment/1.1"=20 xmlns:st=3D"urn://x-artefacts-it-ru/p321/SimpleTypes/1.0"=20 xmlns:ct=3D"urn://x-artefacts-it-ru/p321/ComplexTypes/1.0"=20 xmlns:fo=3D"urn://x-artefacts-it-ru/p321/Step2Form/1.0"=20 xmlns:bo=3D"urn://x-artefacts-it-ru/p321/Application/1.0"><ros:RO = type=3D"VEHICLE_OWNER_DRIVER"=20 id=3D"5672f6f9-176e-42cb-ae76-de1973a77bde"/></ros:relobjects><= BR></DIV> <DIV><B>- i.e. no BO elements at all.</B></DIV> <DIV><BR></DIV> <DIV>Why does this happen? Is there some mistake or undefined behavior = in my=20 stylesheet?</DIV> <DIV><BR></DIV> <DIV>Thank you!</DIV> <DIV>Maksim</DIV></DIV></BODY></HTML> ------_=_NextPart_001_01D12DFE.E06F0A00--