Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Trying to create a secondary XML file in my PT
dlsoderberg
Hello all, and thanks for your help in advance!!
I have a PT that, in the past, created a .jhtml file and worked fine. Now, we're adding some functionality and I need to save off another version of the file as an .xml file. I want to do this using the same PT in the background and have the code seen below at the top of my PT. I'm getting an "Could not process template" error. I based this code off of some pre-existing code found in another area of our site. Any help offered would be greatly appreciated.
<iw_perl>
<![CDATA[
my $path = "/default/main/hr/WORKAREA/load/deploy/docroot/gen/intranet/hrFreeport/repositories/empvoice";
my $bannerImage = iwpt_dcr_value('dcr.Banner_Image');
my $relatedLink = iwpt_dcr_value('dcr.Related_Link');
my $story = iwpt_dcr_value('dcr.Related_Story_Content');
my $month = iwpt_dcr_value('dcr.Live_Date');
my $archive = iwpt_dcr_value('dcr.QA_Archive');
my $header = iwpt_dcr_value('dcr.QA_Header');
my $openData ="<![CDATA[";
my $close1 ="]]";
my $close2 =">";
my $closedData =$close1.$close2;
my $reference = "empvoice_$month.xml" ;
open EV,">$path/$reference";
print EV<<END;
<?xml version="1.0" standalone="no"?>
<document>
<title>EMPLOYEE VOICE</title>
<description>empvoice</description>
<subtitle>$header</subtitle>
<portal>EC</portal>
<reference>$reference</reference>
<image>$bannerImage</image>
<month>$month</month>
<link>$openData$relatedLink$closedData</link>
<content>$openData$story$closedData</content>
<archive>$openData$archive$closedData</archive>
<division>EMPLOYEE</division>
$i=0;
foreach $index ( iwpt_dcr_list( 'dcr.QA_Content_Block' ) )
{
$i++;
my $question = iwpt_dcr_value('index.Employee_Question' ) ;
my $answer = iwpt_dcr_value('index.Employee_Answer' ) ;
iwpt_output("<question" . $i . ">" . $openData$question$closedData . "</question" . $i . ">");
iwpt_output("<answer" . $i . ">" . $openData$answer$closedData . "</answer" . $i . ">");
}
<reference>$reference</reference>
<month>$month</month>
<division>EMPLOYEE</division>
</document>
END
close EV;
]]>
</iw_perl>
Find more posts tagged with
Comments
iwovGraduate
You typically get his when you have some syntax errors in your PT - most likely in the perl code.
Use iwpt_compile with -ocode option to get an .ipl, and run it in debug mode.
For one, you have some code between the statements
print EV<<END;
and
END
Do you want those statements to be printed or exectued ?
You might also want to look at iw_ostream tag or calling a separate/component PT.
dlsoderberg
I made a couple of changes and compiled the code. It is syntactically correct based on the iwperl -w -c command, so I ran the iwperl -d and got this:
Loading DB routines from perl5db.pl version 1.0402
Emacs support available.
Enter h or `h h' for help.
TeamSite:
T:lithiumiw_xml_generated_0:
/teamsite/iwmnt/default/main/hr/WORKAREA/load/gen/intranet/hrFreeport/****.ipl:23):
23: iw_parser_init();
DB<1>
I seem to get this whenever I try to use iwpt_compile to debug things. Here is my code now:
open (EV,">$path/$reference");
print EV<<END;
<?xml version="1.0" standalone="no"?>
<document>
<title>EMPLOYEE VOICE</title>
<description>empvoice</description>
<subtitle>$header</subtitle>
<portal>EC</portal>
<reference>$reference</reference>
<image>$bannerImage</image>
<month>$month</month>
<link>$openData$relatedLink$closedData</link>
<content>$openData$story$closedData</content>
<archive>$openData$archive$closedData</archive>
<division>EMPLOYEE</division>
END
$i=0;
foreach $index ( iwpt_dcr_list( 'dcr.QA_Content_Block' ) )
{
$i++;
my $question = iwpt_dcr_value('index.Employee_Question' ) ;
my $answer = iwpt_dcr_value('index.Employee_Answer' ) ;
print EV<<END;
<question$i>$openData$question$closedData</question$i>
<answer$i>$openData$answer$closedData</answer$i>
END
}
print EV<<END;
</document>
END
close EV;
]]>
</iw_perl>
Dwayne
Umm - the perl interpreter is doing exactly what you asked it to do. The
-d
flag tells perl to go into it's debugger mode, which is indicated by the
DB< 1 >
prompt. It's debugging your script, and asking what you want to do -- single step over the code, read the value of a variable, etc.
As a first step, I suggest running your code WITHOUT the
-d
flag, to see what sort of error/warning messages come up.
--
Current project: TS 5.5.2/6.1 W2K
dlsoderberg
Wouldn't you know it, I didn't get any errors back. Do I need to close the file each time I get to the END statement, and re-open it when I want to continue writing to the file?
Migrateduser
No, not at all -- the -d flag was most likely the culprit.
dlsoderberg
If I try to preview or generate the file, I'm still getting the Preview and Generate Error: Could not process template. But when I ran the iwperl command without the -d, it started spitting out my html below all my perl code.
Migrateduser
I don't recall if you're on a Unix or Windows platform but I had a similar problem a little while back. This may seem trivial, but I had a working PT which compiled just fine on the command line but would not render in TeamSite and I received the same error message you are. I did some reading on the DevNet and in the Support site and found that a few others had the same problem...
My templating.cfg file was corrupted (or, it could also be your PT). Basically, it had "extra" characters that my text editor was putting in. I think all I did to fix it was save it in WordPad and it was just fine.
Failing that, is it possible your user does not have write permissions to generate the temp file it needs to? I looked at that situation before I looked at the other, but it turned out being the file corruption issue.
Dave
dlsoderberg
Problem Solved!!!
Another one of the quirks, I guess. I had to remove all of the spaces/tabs in front of each "END" statement in the PT. Once I backed those to the very beginning of each line (thanks to a tip from a co-worker) the page generates perfectly now.
Thanks for all of your help!
Adam Stoller
That's one of the reasons I tend to stay away from 'hereis' (i.e.: << EOL) type coding.
Rather than something like:
print EV<<END;
<question$i>$openData$question$closedData</question$i>
<answer$i>$openData$answer$closedData</answer$i>
END
I'll tend to use either:
print EV qq(<question$i>$openData$question$closedData</question$i>
<answer$i>$openData$answer$closedData</answer$i>\n);
or:
print EV join("\n",
"<question$i>$openData$question$closedData</question$i>",
"<answer$i>$openData$answer$closedData</answer$i>\n");
The first alternative is a bit better performance wise than the second, but one of the editors I use doesn't indent properly for qq(...) where it does for join(...) so I choose whichever I feel like and I don't have to worry about fixing indentation in my code breaking the code (
although with qq(...) the white-space on the lines will be kept in the output, so it *might* break the output code depending on what you're generating
)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com