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)
iw_load_dcr
patc
TeamSite 5.5.2 on Windows.
Hello,
I am trying to include some content from one XML file into a template generated XML file.
Using iw_load_dcr tag in a TPL to load some arbitrary XML file is working fine.
<iw_load_dcr var='a' file='$articlelink' mode='cwd'/>
When I try to reference an element of the XML I am getting problems.
The XML looks like this
<page>
<page.type>newsarticle</page.type>
</page>
However, the tag below returns blank. I think this is because it cannot handle the XML element page.type.
<iw_value name='a.page.page.type'>
Does anyone know a way around this? Maybe by using some escape characters to escape the . character in page.type
It works fine if the . character is not in the element name.
Let me know if I need to explain this better.
Thanks.
Pat
Find more posts tagged with
Comments
cliffhanger
Perhaps you could try using
page.page\.type
Edited by cliffhanger on 06/10/05 08:39 AM (server time).
patc
Thanks,
I tried this one but I get a TPL Parsing error. I cannot use the \ in the iw_value tag.
LooseCannon
You should ALWAYS avoid using "." and "-" in element names, because, as you found out, applications handle the punctuation differently. Make life easy on yourself and replace the "." with an "_".
If you're still bent on using the "." try :
<iw_value name='a.page.page\\.type'>
patc
Thanks for your response!
I accept that the . character is going to cause us problems but we are unable to replace it at this stage.
We have hundreds of XML files in this format already
Using the \\. is allowed by the TPL Parser but still results in an empty tag.
I believe this is just escaping the \ character - not the . character?
I have tried a few combinations of this now.
My other alternative seems to be using the XML:
arser Module and trying to retrieve the value
with XPATH? I know this is messy but it's the only thing I can think of.
Any other suggestions greatly appreciated.
Adam Stoller
Using the \\. is allowed by the TPL Parser but still results in an empty tag.
I believe this is just escaping the \ character - not the . character?
It sometimes takes several attempts to get this right - depending on the number of levels you need to be able to process through.
Generally try all of the following:
foo\\.bar
foo\\\.bar
foo\\\\.bar
foo\\\\\.bar
foo\\\\\\.bar
foo\\\\\\\.bar
Depending on the number of layers of processing being gone through - one of these should provide the correct number of escape characters to eventually get you to the point where you are escaping just the '.'
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
patc
Thanks again for prompt replies!
I have tried this many many times now. Right up to 16 \ characters.
Basically, it doesn't Parse at all with an odd number of \ chars, and returns blank with an even number.
I still can't escape the . char to find the element <page.type>
The XML just looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<page>
<page.type>newsarticle</page.type>
</page>
My Load DCR tag is
<iw_load_dcr var='a' file='$articlelink' mode='cwd'/>
<iw_value name='a.page.page\\\\\\.type'>
Any other suggestions, has anyone done this using XML:
arser?
Adam Stoller
The only thing I can think of at this point in time is a hack work-around solution - where once you know the name of the DCR to be read in - you read it in with your own routine, modify the element names that contain '.'s, write it out again as a temporary file and then load that temporary file as the DCR.
I.e. - If I know I need to load DCR "foo" - then before I load it I read it in as basic text and run some regex over the whole thing like [UNTESTED]:
...
sub preload{
my $dcr = shift;
my $xml = '';
if (open(IN, "<$dcr")){
local $/;
$xml = <IN>;
close(IN);
}
$xml =~ s|<([^\.>])\.([^>])>|<${1}_$2|sgmo;
if (open(OUT, ">$dcr.tmp")){
print OUT $xml;
close(OUT);
}
}
...
preload("/default/main/.../data/foo");
iwpt_dcr_load("/default/main/.../data/foo.tmp");
At this point you should [hopefully] be able to reference things like:
<iw_value name='a.page.page
_
type'>
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
patc
Thanks Ghoti,
I have implemented a similar workaround and it seems to work fine.
I know it's not ideal, but thanks very much for all the help.
Pat.