1

there is a java tool that uses several xsl transforms to convert data out of crx into esi xml markup.

often esi markup is non valid xml because esi is often small snippets of logic that do not always have the same opening and closing tags. ex:

<esi:assign>

bunch of esi logic

<esi:vars>$(myVar)</esi:vars>

the java xsl engine currently does not allow xml to be generated if it is invalid. Because of this we have to wrap all esi output in dummy tags but this causes several problems.

So I am wondering if there is a way to allow java xsl transform engine to generate invalid or not well formed markup?

Thanks.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
Arya
  • 115
  • 1
  • 3
  • 7
  • Any intermediate output on which you'll use more XSL transforms needs to be valid XML (because XSL only works on XML), but I'm pretty sure the final output can be anything. Which "Java XSL engine" are you using? – zneak Apr 04 '11 at 14:03
  • Do note that this is not well formed XML but valid SGML then you could use [DSSSL](http://www.mulberrytech.com/dsssl/) –  Apr 04 '11 at 14:44

2 Answers2

0

Set the output mode to text (instead of the default xml). Now, you can generate any kind of text (even if it looks a lot like XML) but you have to make sure for yourself that characters like <, >, etc. are properly escaped in the right places.

Also things like xsl:element won't work anymore for obvious reasons.

Maybe you're better off writing things like that in a real programming/scripting language than in XSL.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • @Aaron Digulla: What is the meaning of "real programming/scripting languege than in XSL"? –  Apr 04 '11 at 14:33
  • XSL is a very specialized script-like language which has lots of limitations and places where you want to bang your had on the table to make the pain bearable :-) That's why you're often better off using a general purpose scripting language like Python. – Aaron Digulla Apr 04 '11 at 15:05
  • @Aaron Digulla: I think you want to say that **XSLT** is a high-level declarative language with specialized execution context. –  Apr 04 '11 at 15:16
  • @Alejandro: What I want to say is that XSLT is too complex for 95% of all developers out there and too limited for anything but simple "filter elements" problems. – Aaron Digulla Apr 04 '11 at 15:18
  • @Aaron Digulla: You have the right to any opinion on the matter. But I think you adjective too much. –  Apr 04 '11 at 15:26
  • Thanks Aaron for the useful information. seems like changing the method to text comes with the cost of losing the features of xml. That is why I was basically looking for a way to turn off xml validation on generating the document without having to change the method to text. I am using the following packages. javax.xml.transform.OutputKeys; javax.xml.transform.Transformer; javax.xml.parsers.DocumentBuilder; javax.xml.transform javax.xml.xpath.XPath; – Arya Apr 15 '11 at 13:07
  • XML without validation doesn't make sense because then, it's no longer XML. So I can't help you there. – Aaron Digulla Apr 15 '11 at 14:19
0

If you can alter the xsl transforms, you can use :

<xsl:output method="text">
Stephan
  • 41,764
  • 65
  • 238
  • 329
  • Thanks Stephan for the answer but I was wondering if there was a way to turn off xml validation on generating the document without having to change the method to text. – Arya Apr 15 '11 at 13:04
  • @Arya Simply no ! If the output method is XML , the produce code MUST be valid XML : closed tags, attributes with quotes etc. Sorry :\ – Stephan Apr 15 '11 at 14:39