We help IT Professionals succeed at work.
Get Started

XML to PDF, attributes with spaces

nebb-tgr asked
Last Modified: 2012-05-10

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.
Watch Question
Information Architect
Top Expert 2006
This problem has been solved!
Unlock 1 Answer and 19 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE