Avatar of nebb-tgr

asked on 

XML to PDF, attributes with spaces


We recieve several XML-documents that we need to convert to PDF. I have downloaded the apache-FOP and tried converting the documents, but I'm having some trouble with some of the attribute names.

This is a simplified version of the XML-document:
<?xml version="1.0" encoding="UTF-8" ?>
<test test="testing" anothervariable="testing2" \>

This is a simplified version of the XSL-document:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"

<xsl:template match="/">

<xsl:template match="config">
  <xsl:apply-templates select="test test"/>
  <xsl:apply-templates select="anotervariable"/>

<xsl:template match="test test">
  Title: <span style="color:#ff0000">
  <xsl:value-of select="."/></span>
  <br />

<xsl:template match="anothervariable">
  Artist: <span style="color:#00ff00">
  <xsl:value-of select="."/></span>
  <br />


Open in new window

The command I'm running to convert the file is:
fop -xml xmldocument.xml -xsl xsldocument.xsl -pdf pdfdocument.pdf

I have never worked with xml or xsl, so I have no idea where to begin. But it seems the problem occurs when a variable name contains a space. If the variable is named test_test, it would work. If I name the variable test test, it fails.
XMLDocument ManagementJava

Avatar of undefined
Last Comment

8/22/2022 - Mon