0

Recently upgraded from Saxon HE 9.7-8 to 10.5-he.jar

In one of my XSL file, not able to store the data in a variable when I am running on Jboss server EAP 7.3 and JDK 11 . Where as the same is working when I have tested in command prompt or the debugger tool.

XSL file

We are using the below namespace

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0" xpath-default-namespace="http://hl7.org/fhir"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:f1="urn:hl7-org:v3"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cda="urn:hl7-org:v3"
  xmlns:sdtc="urn:hl7-org:sdtc" xmlns:lookup="http://lookup.data"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="fn lookup sdtc xsl cda f1 xsi" xmlns:fn="http://www.w3.org/2005/xpath-functions">

<!--loading the XML file by using the below code. here medicalSystems is a global variable-->
<xsl:variable name="medicalSystems" select="document('medicalsystems.xml')"/>

<!--then we are trying to store the data the variable ms-->
 <xsl:param name="this" select="."/>
    <xsl:param name="code" select="."/>
    <xsl:param name="doc" select="/"/>    
     <xsl:variable name="ms"
      select="$medicalSystems/Bundle/entry/coming/MedicalSystem[url/@value = $this]"/>

XML file content:medicalsystems.xml
<Bundle xmlns="http://hl7.org/fhir">
  <entry>
    <coming>
      <MedicalSystem>
        <url value="http://cancer.sanger.ac.uk/"/>
        <identifier>
          <system value="urn:ietf:rfc:3986"/>
          <value value="urn:oid:2.16.840.1.113883.6.283"/>
        </identifier>
        <name value="COSMIC : Catalogue Of Somatic Mutations In Cancer"/>
      </MedicalSystem>
    </coming>
  </entry>

We have confirmed that the XML is loading properly in the class where as the variable ms is empty when we execute on Jboss. The same piece of code working fine when we are executing with Saxon9.7 version . Any input will be helpful.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110
Sumit
  • 1
  • 2
  • We don't see what `$this` or `.` is so it is hard to tell. Which checks do you run to see that "the XML is loading properly"? Can you `trace($medicalSystems)` or `` or insert e.g. `` in the output? If all the previous checks show the content you expect, can you output `namespace-uri($medicalSystems/*)`? – Martin Honnen Aug 24 '21 at 18:02
  • Is this an attempt to solve the problem already raised in https://stackoverflow.com/questions/68817415/unable-to-load-xml-document-with-document? Or are two different persons running into a very similar problem? Nevertheless, the last questions in the comment sections were not answered. – Martin Honnen Aug 24 '21 at 18:37
  • Please try using doc() rather than document() as this may give better diagnostics. – Michael Kay Aug 24 '21 at 21:51
  • @MartinHonnen We have added this code " count(doc('urls.xml')) " which gives 1 in the output, by which we are making sure the XML is loading in XSL file – Sumit Aug 25 '21 at 05:44
  • Does that comment about `urls.xml` refer to the previous question? Here the file seems to have a different name. And we can't debug this current question if you don't provide more information. – Martin Honnen Aug 25 '21 at 07:40
  • @MartinHonnen Yes, both the questions are related. The XML file name and the file which we are loading in XSL are same 'medicationsystem.xml' . The output of namespace-uri($medicalSystems/*) came as "http://hl7.org/fhir" which is default namespace in XSL file also available in XML file – Sumit Aug 25 '21 at 10:50
  • @MichaelKay we have used doc() instead of document() but did not t got any clue. $this holds a value like "http://cancer.sanger.ac.uk/" . – Sumit Aug 25 '21 at 11:04
  • It is not really possible to tell why the code would fail in a certain environment without access to that environment. Does `$medicalSystems/Bundle/entry/coming/MedicalSystem` at least select all elements you expect, including the one with `url/@value = 'http://cancer.sanger.ac.uk/']`? – Martin Honnen Aug 25 '21 at 13:12
  • Tried to output "$medicalSystems/Bundle/entry/coming/MedicalSystem" this got empty value. while printed " $medicalSystems/Bundle" got values like " .." . I guess something going wrong while applying namespace, or may be the default-namespace in XSL and XML file. Please provide your thoughts – Sumit Aug 26 '21 at 10:35
  • Start editing your question and showing precise and complete, formatted details of the debug attempt, i.e. the values of the various expressions you have tested. I can't infer anything from some shortened data thrown into a comment. – Martin Honnen Aug 26 '21 at 15:43
  • I am printing the statement in this way : output of all these statement is coming as empty( testSystem="") "$medicalSystems/Bundle/entry/coming/MedicalSystem" "$medicalSystems/Bundle/entry/coming" "$medicalSystems/Bundle/entry" output of this "$medicalSystems/Bundle" statement gave values like this " " – Sumit Aug 26 '21 at 16:48
  • Please edit your question and add any code samples there in a formatted and therefore easily readable way. And that using `` doesn't output anything can't surprise anyone, after all, judging from the sample, all data is in attribute values of child or descendant elements, so that attempt to output the string value of the element which doesn't contain any text data children or descendants can't show anything. So use `xsl:message` or `` – Martin Honnen Aug 26 '21 at 17:23
  • This is the only code sample which I am trying to solve. I have used xsl:message added the below statements it has printed empty value in the response(testSystem=""). Added Which is giving me one liner response only i.e "" in the Jboss, when I executed in a debugger tool it gave the entire data. – Sumit Aug 27 '21 at 14:44
  • Start selecting e.g. ``, then e.g. ``. – Martin Honnen Aug 27 '21 at 15:44
  • After adding or is giving stylesheet compilation issue. but when I executed same in Altova debugger the entire value printed in output xml. Do you think the solution which mentioned in the below link is related? https://stackoverflow.com/questions/30014337/how-do-i-enable-xslt-2-0-processor-in-jboss-eap-6-1-server-to-get-rid-of-errors . Any help will be greatly appreciated – Sumit Sep 01 '21 at 12:26
  • getting extra namespace in the top level of the output xml with Saxon10.5 jar e.g " " . where as with 9.7.0-8 we are not getting that e.g "
    "
    – Sumit Sep 01 '21 at 13:51
  • Can you please consider to edit your question and insert any information there in a formatted way? The question shows `` as the root element of the file you load, which file do you show in your debug information that has a `component` (root?) element? As for the namespace differences, I think were are getting closer to explain the failure to select elements, but currently I am not sure where the difference comes from. Are parts of the documents built outside of XSLT/Saxon, with the DOM API? – Martin Honnen Sep 01 '21 at 16:15
  • All the xml will be build in side the DOM only .In the question which shows "" this in the medicalsystems.xml which we are loading into the Portion.xsl and fetching data from that . The Component is the root element of the final output xml . In the XSL file we have exclude-result-prefixes to avoid the namespaces . – Sumit Sep 03 '21 at 09:48
  • @MartinHonnen We debugged the application and came across one difference where we saw empty name space in medicalsystems.xml file which we have printed the stream before transformation and with latest jar. difference is an extra xmlns="" as a part of ..... seems like something to do with namespace. refereed to other questions which you have answered . But still not working https://stackoverflow.com/questions/68347520/xslt-element-selection-based-on-another-variable An input will be helpful – Sumit Sep 16 '21 at 13:30

0 Answers0