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)
metadata
har
We are going to implementing metadata capture using TS6.1, without metatagger. I would like to automate as much as possible for the users. Is there a way to pull fields from the dcrs ( last modified, title, created date)
Find more posts tagged with
Comments
Ravidialog
Hi,
I am also doing the same thing to get the title from dcr to metadata.
as follows.
use TeamSite::XMLparser;
open(DCR, "PATH_TO_DCR") or die("$! - Cannot open DCR (r)...get helpfrom the teamsite admin");
local $/=undef;
my $xml = <DCR>;
close DCR;
select STDOUT;
my $parser = TeamSite::XMLparser->new();
my $rootnode = $parser->parse($xml);
my $job_status=$rootnode->value("job_status");
but does not work, please help me.
ravi
gzevin
you might let your presentation template attach metadata while it's generating the file.
and it's obviously up to your presentation logic how and what you want to attach.
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Ravidialog
Hi gzevin
In my case the metadata field in Title is entered by users. and I want to get it from DCR which i created and the metadata field title shows the title.
if the user wants to edit the field it is possible. I need a perl script sample to do this.
ravi
gzevin
after you attach the Title as metadata, you'd need to decide as to where you want to capture it - still in a DCT or in a metadata capture template. Or in both.
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Ravidialog
Hi gzevin,
I have configured the metadata datacaptur.cfg in such a way that.
<item name="Title">
<database data-type="VARCHAR(240)" />
<text required="f">
<inline command="e:/teamsite/iw-perl/bin/iwperl e:/teamsite/httpd/iw-bin/custom/getdcrtitle.ipl" />
</text>
</item>
I want the sample for
getdcrtitle.ip script.
Ravi
gzevin
I am afraid you don't have a clear picture of what you are trying to acheive.
if you ask me, you need to spend more time in understanding on how the whole architecture works, before writing any scripts.
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Ravidialog
Hi,
I am trying to use the following code to extract Title inf from DCR.
It does not give any results. but print $xml print the file for me.
Please help
use TeamSite::XMLparser;
my $dcr ='E:\TeamSite\httpd\iw-bin\custom\test_ravi.dcr';
open(DCR, $dcr) or die("$! - Cannot open DCR (r)...get helpfrom the teamsite admin");
local $/=undef;
my $xml = <DCR>;
close DCR;
print $xml;
my $parser = TeamSite::XMLparser->new();
my $rootnode = $parser->parse($xml);
my $title=$rootnode->value("Title");
print $title;
gzevin
I can offer you a snippet of code that will read a DCR. however, let me repeat again - you should try to understand the architecture and you will see that metadata capture record by itself is not aware of any DCRs and it does not have necessary API that would help you with this.
however, just to read a value from a DCR, you could use this:
use TeamSite:
CRnode;
open (DCR,"<$dcr]") or warn "could not open $dcr";
my
@dcr
= <DCR>;
close DCR;
my $xml_string=join("",
@dcr)
;
my $rootnode = TeamSite:
CRnode->new($xml_string);
my $title = $rootnode->value('Title');
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Ravidialog
Hi,
Thanks for the reply. I need to solve this very urgently.
The following code print me
Entire DCR file ...
and
TeamSite:
CRnode=ARRAY(0x1d6aac8)
there is no Title vale. But I check the DCR having Title.
please help.
use TeamSite:
CRnode;
my $dcr1='Y:\default\main\internet_test\doh\WORKAREA\osd\templatedata\health\pubs\data\2004\testing.dcr';
open(DCR,$dcr1) or die "could not open $dcr1";
my
@dcr
= <DCR>;
close DCR;
my $xml_string=join("",
@dcr)
;
print $xml_string;
my $rootnode = TeamSite:
CRnode->new($xml_string);
print $rootnode;
my $title = $rootnode->value('Title');
print $title;
ravi.
gzevin
what is the structure of your DCR?
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Ravidialog
Here my format.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE record SYSTEM "dcr4.5.dtd">
<record name="investigation.dcr" type="content"><item name="pubs"><value><item name="SortDate"><value>20040421</value></item>
<item name="Filename"><value>2004/investigation</value></item>
<item name="Name"><value>investigation</value></item>
<item name="Title"><value>Investigation into the possible health impacts of the M5 East Motorway Stack on the Turrella communi</value></item>
<item name="Summary"><value>The M5 East motorway is a 10 km long, four-lane dual carriage motorway, which links central Sydney with Sydney’s southwest. Four kilometres of the M5
East motorway is a tunnelled section which is ventilated via a single exhaust stack, located in Turrella.The tunnels opened to traffic in December 2001 and are used by over 82 000 vehicles daily, with 6.9 per cent being heavy vehicles.</value></item>
<item name="ImageLink"><value>/images/pubs/2004/ab_evaluation.gif</value></item>
<item name="WholeFileLinkText"><value>Investigation into the possible health impacts of the M5 East Motorway Stack on the Turrella communi</value></item>
<item name="WholeFileUrl"><value>/pubs/2004/pdf/carhome_fs.pdf</value></item>
<item name="FileLinks"/>
<item name="Type"><value>report</value></item><item name="Date"><value>21/04/2004</value></item>
<item name="SHPN"><value>040055</value></item>
<item name="ISBN"><value>0 7347 36592</value></item>
<item name="ISSN"><value/></item>
<item name="Subjects"><value><item name="Subject1"><value>environ</value></item><item name="Subject2"/><item name="Subject3"/><item name="Subject4"/><item name="Subject5"/></value></item>
<item name="RelatedLinks"><value><item name="LinkText"><value/></item>
<item name="Url"><value>
http://www.health.nsw.gov.au/</value></item>
</value></item>
</value></item></record>
gzevin
Well, try this:
my $title = $rootnode->value('pubs.Title');
you should analyse the structure of your DCRs, don't you?
Say hi to Rob Gerega from me
I hope that you will know how to do with the rest of what you need to do....
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Ravidialog
Thanks a lot. It works fine.
Ravi.
Alessandro
I have a similar predicament...
I tried your suggestion on this post, however, it fails at the "my $rootnode = TeamSite:
CRnode->new($xml_string);" line below:
use TeamSite:
CRnode;
my $dcr1='Y:\default\main\disc\WORKAREA\COMMON\templatedata\disc\standards\data\sys.dcr';
open (DCR,"<$dcr1]") or warn "could not open $dcr";
my
@dcr
= <DCR>;
close DCR;
my $xml_string=join("",
@dcr)
;
my $rootnode = TeamSite:
CRnode->new($xml_string);
my $title = $rootnode->value('metadata.title');
print <<EOF;
<?xml version='1.0' encoding='UTF-8'?>
<substitution><default>$title</default></substitution>
EOF
Appreciate the help in advance...
Adam Stoller
This is horribly inefficient and incorrect (in terms of error handling) code, and it contains at least one typo:
open (DCR,"<$dcr1
]
") or warn "could not open $dcr";
my
@dcr
= ;
close DCR;
my $xml_string=join("",
@dcr)
;
This would be better:
my $xml_string = '';
if (open (DCR,"<$dcr1")){
local $/;
# temporarily undefine the end-of-line identifier
$xml_string = ;
# slurp in the whole file all at once and avoid running a 'join'
close DCR;
}
if ($xml_string eq ''){
# ... error handling code ...
}
else {
# ... code for processing the dcr
}
As it stands right now, you don't know where that
warn()
message will go and even though you've apparently failed to open the file, you're going to continue trying to process the contents of the file that you weren't able to read. And thus you can't be sure whether the reason the code is failing is because you weren't able to open that file or for some other reason. (
and you're using
$dcr
for the error message when the variable is actually
$dcr
1
and thus the debugging message won't help even if you do see it somewhere
).
Eliminate the confusion over where the error is actually occurring and then you can focus in on what's actually happening.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
gzevin
what is so horribly inefficient about this? the typos could come cause I probably the code was simply typed in.
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Adam Stoller
It's much less efficient to read a file, line by line, into an array and then use join to make it a single string value -- rather than reading the entire file into a string in one step. I've attached a script you could use to verify this on your own system - assuming you save the file as something like "foo.ipl" (and adjust the first line in the script - especially if running on Unix) - run the script like this:
foo.ipl
(
no arguments -- this will verify that the routines accomplish generating the same size string
)
foo.ipl 1000
(
the number you provide determines the number of iterations to use for benchmarking, generally 1000 is about the smallest number you can use with reasonable results
)
On my G4 Mac with 1Gb RAM I see the following results:
/tmp >
./foo.ipl 1000
Benchmark: timing 1000 iterations of ghoti_create, ghoti_read, gzevin_create, gzevin_read...
ghoti_create: 12 wallclock secs ( 1.34 usr + 2.21 sys = 3.55 CPU) @ 281.69/s (n=1000)
ghoti_read: 1 wallclock secs ( 0.11 usr + 0.12 sys = 0.23 CPU) @ 4347.83/s (n=1000)
(warning: too few iterations for a reliable count)
gzevin_create: 16 wallclock secs ( 3.50 usr + 2.08 sys = 5.58 CPU) @ 179.21/s (n=1000)
gzevin_read: 13 wallclock secs ( 4.62 usr + 0.37 sys = 4.99 CPU) @ 200.40/s (n=1000)
/tmp >
./foo.ipl 10000
Benchmark: timing 10000 iterations of ghoti_create, ghoti_read, gzevin_create, gzevin_read...
ghoti_create: 119 wallclock secs (13.17 usr + 22.39 sys = 35.56 CPU) @ 281.21/s (n=10000)
ghoti_read: 5 wallclock secs ( 0.86 usr + 1.27 sys = 2.13 CPU) @ 4694.84/s (n=10000)
gzevin_create: 186 wallclock secs (34.30 usr + 22.26 sys = 56.56 CPU) @ 176.80/s (n=10000)
gzevin_read: 144 wallclock secs (45.96 usr + 4.09 sys = 50.05 CPU) @ 199.80/s (n=10000)
On a Sun Ultra-250 with about 750 Mb RAM I see the following results:
/tmp >
./foo.ipl 1000
Benchmark: timing 1000 iterations of ghoti_create, ghoti_read, gzevin_create, gzevin_read...
ghoti_create: 5 wallclock secs ( 2.80 usr + 1.60 sys = 4.40 CPU) @ 227.27/s (n=1000)
ghoti_read: 0 wallclock secs ( 0.31 usr + 0.22 sys = 0.53 CPU) @ 1886.79/s (n=1000)
gzevin_create: 11 wallclock secs ( 8.79 usr + 1.43 sys = 10.22 CPU) @ 97.85/s (n=1000)
gzevin_read: 15 wallclock secs (14.82 usr + 0.18 sys = 15.00 CPU) @ 66.67/s (n=1000)
/tmp >
./foo.ipl 10000
Benchmark: timing 10000 iterations of ghoti_create, ghoti_read, gzevin_create, gzevin_read...
ghoti_create: 42 wallclock secs (25.15 usr + 16.82 sys = 41.97 CPU) @ 238.27/s (n=10000)
ghoti_read: 5 wallclock secs ( 2.71 usr + 2.46 sys = 5.17 CPU) @ 1934.24/s (n=10000)
gzevin_create: 102 wallclock secs (87.07 usr + 14.80 sys = 101.87 CPU) @ 98.16/s (n=10000)
gzevin_read: 150 wallclock secs (147.09 usr + 2.48 sys = 149.57 CPU) @ 66.86/s (n=10000)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
gzevin
common, it's not 100 times faster
. Parsing will consume most of the time anyway.
coming from a parallel processing background, I usually more concerned about innermost loops, that eat up most of the processing time.
but I apreciate you took some time to evaluate
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU