Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ppc_michael

Guest
Original poster
Apr 26, 2005
1,498
2
Los Angeles, CA
I'm working with InDesign CS3.

I've written a document in XML and I'm trying to bring it over to InDesign to format it for print. I've imported it and assigned the tags to styles, and I think that's pretty cool.

But! I have a problem with whitespace. In my XML file, I've done things like indented child elements (am I not supposed to do that?), and those tabs show up in InDesign as whitespace in the text. Oops.

Is there a way I can make those tabs go away in InDesign, while preserving them in the XML file (because it looks nicer, for when I go to edit it)? I've read about XSLT but wouldn't know how to write one, is that my only option? I'm hoping for some sort of checkbox in InDesign. ;)

Thanks!
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
Something like that is definitely application specific. I've never used inDesign so not sure how it works, but I do use XML a bit and know whitespace matters. If no one knows a way to tell InDesign to treat whitespace differently I could probably come up with an XSLT for you ... maybe. I haven't tried your specific situation, but I think it can be fairly easily done.
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
OK, I through this together pretty quickly using random tags:

Input XML using tab indenting:
Code:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<test>
	<el>text</el>
	<li>
		<do>something</do>
	</li>
	<am>ahahfn</am>
	<sd>dc thif md</sd>
</test>

The XSLT to transform the above XML:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>
  <xsl:template match="*">
    <xsl:copy-of select="."/>
  </xsl:template>
</xsl:stylesheet>

The Output XML that results, indented with spaces only:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<test>
  <el>text</el>
  <li>
    <do>something</do>
  </li>
  <am>ahahfn</am>
  <sd>dc thif md</sd>
</test>

The resulting XML if you change the output tag's attribute "indent" to "no":
Code:
<?xml version="1.0" encoding="UTF-8"?>
<test><el>text</el><li><do>something</do></li><am>ahahfn</am><sd>dc thif md</sd></test>

Hope that works for you.
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
Wow, that's just what I need. Thank you so much for taking the time to write that for me!

Cool, glad that was what you needed. Just out of curiosity, which output style did you end up using? With indent set to "yes" or "no"? It may help someone down the line to know the specifics.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.