5

I try to set XSL property for my marshaller like this (which I copied from here) :

marshaller.setProperty("com.sun.xml.bind.xmlHeaders",
                "<?xml-stylesheet type='text/xsl' href=\"" +
                        xslFileName +
                        "\" ?>");

But it causes javax.xml.bind.PropertyException with this message :

name: com.sun.xml.bind.xmlHeaders value: <?xml-stylesheet type='text/xsl' href="decathlon.xsl" ?>

"very informative"

Sorry, but I cannot elaborate more, frankly I have no idea what causes this.

Community
  • 1
  • 1
Ben
  • 3,989
  • 9
  • 48
  • 84
  • Possible duplicate of [How to add DOCTYPE and xml processing instructions when marshalling with JAXB?](http://stackoverflow.com/questions/2919294/how-to-add-doctype-and-xml-processing-instructions-when-marshalling-with-jaxb) – lexicore Oct 19 '15 at 06:37

2 Answers2

6

I managed to find this answer, which solved my problem. All i had to do to replace the com.sun.xml.bind.xmlHeaders property with com.sun.xml.internal.bind.xmlHeaders.

Community
  • 1
  • 1
Ben
  • 3,989
  • 9
  • 48
  • 84
0

I had the same issue while upgrading to Springboot 3 with JDK 17. I solved the issue with:

marshaller.setProperty("org.glassfish.jaxb.xmlHeaders", "<?xml-stylesheet type='text/xsl' href='/xsl/transformation.xsl' ?>");

groupId:jakarta.xml.bind, artifactId:jakarta.xml.bind-api, version:4.0.0
groupId:org.glassfish.jaxb,artifactId:jaxb-runtime, version:4.0.3, scope:runtime
Procrastinator
  • 2,526
  • 30
  • 27
  • 36