Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

creating RDF with smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Galois
Smarty Rookie


Joined: 02 May 2003
Posts: 16

PostPosted: Sat Jul 26, 2003 1:15 am    Post subject: creating RDF with smarty Reply with quote

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
View user's profile Send private message Send e-mail
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Jul 26, 2003 4:44 am    Post subject: Reply with quote

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
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sat Jul 26, 2003 1:53 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Jul 27, 2003 6:37 pm    Post subject: Reply with quote

and AFAIK smarty doesn't emit newlines neither after "{foreach}" nor after "{/foreach}".
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Galois
Smarty Rookie


Joined: 02 May 2003
Posts: 16

PostPosted: Mon Jul 28, 2003 10:34 pm    Post subject: litteral Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP