|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Galois Smarty Rookie
Joined: 02 May 2003 Posts: 16
|
Posted: Sat Jul 26, 2003 1:15 am Post subject: creating RDF with smarty |
|
|
I am trying to generate an RDF file with Smarty, but I am getting a blank line after {/foreach} which is breaking the file.
I am surrounding all the xml with {literal} to get rid of as much whitespace as possible, but can't get rid of the blank line after {/foreach}
anyone run across this before and know a workaround?
Code: |
{literal}
<?xml version="1.0"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:things="http://www.xulplanet.com/rdf/example#">{/literal}
{foreach from=$cols item=col key=key}
<RDF:Description about="urn:things:{$key}" things:name="{$col}"/>
{/foreach}{literal}<RDF:Seq about="urn:things:root">
<RDF:li>
{/literal}{foreach from=$cols item=col key=key}
<RDF:Seq about="urn:things:{$key}" />
{/foreach}{literal}</RDF:li>
</RDF:Seq>
</RDF:RDF>
{/literal}
|
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Jul 26, 2003 4:44 am Post subject: |
|
|
I didn't realize that xml was sensitive to linebreaks (?)
I may be reading this wrong, but this doesn't look right:
<RDF:Seq about="urn:things:{$key}" />
{/foreach}{literal}</RDF:li>
</RDF:Seq>
should it not be
<RDF:Seq about="urn:things:{$key}" >
{/foreach}{literal}</RDF:li>
</RDF:Seq>
??
But then the {/foreach} looks misplaced... |
|
Back to top |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sat Jul 26, 2003 1:53 pm Post subject: |
|
|
AFIK XML is sensetive to line breaks but you could always run it through the {strip}...{/strip} block _________________ "Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sun Jul 27, 2003 6:37 pm Post subject: |
|
|
and AFAIK smarty doesn't emit newlines neither after "{foreach}" nor after "{/foreach}". |
|
Back to top |
|
Galois Smarty Rookie
Joined: 02 May 2003 Posts: 16
|
Posted: Mon Jul 28, 2003 10:34 pm Post subject: litteral |
|
|
the problem was {literal} was adding the blank lines. I futz with it enough to get rid of the breaks in the wrong places.
XML is sensivite only in certain locations. Depends on how the dataset is structured.
also, adding
Header("Content-Type: text/xml");
to the php
helped a lot. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|