Question

I have a program that uses XSL-FO (org.apache.fop.apps.Driver) to generate a PDF print out from an XML file.

I'm working on the Stylesheets (xsl) & I'm trying to make the debugging easier. I have the XML & the XSL file, now I just want my editor to show me the generated PDF as I'm working on the XSL file.

I tried several editors & they gave errors that the program doesn't seem to have a problem with.

it seems that the problem is that the editor expects to see :

<ATTRVALUE attribute_id="92" attrname="Date Required" attr_value="" />

while the actual XML the program generates is

<ATTRVALUE attribute_id="92" attrname="Date Required" attr_value />

As you can see the empty attr_value is plainly missing the ="" - is there a way for me to make the editor less strict? So it can generate the PDF just like the program I have does?

Was it helpful?

Solution

<ATTRVALUE attribute_id="92" attrname="Date Required" attr_value />

That line is invalid as has been mentioned before. The program that thinks it's okay is probably using it's own custom XML parser which will just ignore these invalid attributes. It makes me have doubts about the programming qualities of the people who created that program. It just seems to me that they're just writing this XML as text instead through an XML-DOM mechanism. Still, that should be okay but unfortunately, their code has a bug.

Most -if not all- XML editors, parsers and transformers will validate the XML before it's processed. So unfortunately there's no good solution to fix this problem from within the XSLT file. Using a RegEx, you could remove the invalid attributes or make them valid by appending ="" to them, but there's no way to do this before the XSLT will validate the XML.

To solve this, the program needs to be changed to generate valid XML. Because right now, this could be considered a very serious bug. (Unless the program just uses this fake XML for internal purposes.)

OTHER TIPS

The XML with the attr_value and no = is invalid W3C XML specification and so all XML tools should complain. What tool are you using?

Ok, I've just used the Regular Expression Find & replace all attribute names, if they don't end with ="" then add that, now everything seems to be ok... lame, but it's ok for my needs at the moment

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top