Home
TeamSite
XML::Writer?
System
I've mostly done XML document creation with Java and C# so now that I need to get it done with Perl I'm a little lost. What tools are available for this with the default Interwoven installation? I can find XML::Writer on CPAN but it doesn't seem to ship with TeamSite. I'd rather use the default modules provided with the system if possible.
Find more posts tagged with
Comments
Gregg Faus
I use XML::Writer extensively to write out XML files that are used in various custom website applications. It is very easy to use and works in a similar fashion as the equivalent .NET framework class (XmlTextWriter).
I know it's not a default module, but a lot of the good modules aren't.
Let me know if you need some code examples.
Migrateduser
Yeah it seems pretty straightforward. One thing I can't figure out is how to make it write to a variable (StringWriter/StringBuffer) instead of a file or STDOUT though. Any gussetions?
Gregg Faus
Well the documentation states that the OUTPUT can be an object blessed into IO::Handle or one of its subclasses (such as IO::File). I'm not a PERL junkie so I don't know if that equates to allowing a variable trick or not.
Here is the documenation for anyone else that would know:
http://search.cpan.org/~dmegg/XML-Writer-0.4/Writer.pm
Migrateduser
Do you have any examples of taking existing DCRs that need to be restructured (items moved into containers, etc.)?
Migrateduser
I read those docs pretty thoroughly and couldn't figure it out. It's probably related to my other recent post (how to redirect STDERR/STDOUT when you don't own the command line). My guess is that Fish has the answer. I guess I can pass and slurp a temp file but that's silly.
This stuff is so easy in Java and .net, Perl is sooo frustrating...
Gregg Faus
Most of my examples that I could give do mostly the same thing. Which is:
1) Open tempatelate data directory passed in as an argument to the .ipl file
2) Iterate through data directory
3) For each DCR, write out specifc information that I need captured into the XML file
4) Save XML file
However, I don't have what you specifically asked for. That is to reformat a DCR by moving it around. I would think other modules would work better for that. This module is great for creating brand new XML files in a fast and straighforward way.
Adam Stoller
From other threads that have appeared in the forums (I believe in the templating forum) - I believe the pervasive suggestion has been to use XSLT to transform DCRs who's DCT structures have changed (and then set the EAs as needed).
If you believe that XML::Writer is a valuable module to have in the distribution, contact Interwoven Support and file a feature request. Otherwise, you can probably install it into something like IWHOME/local/lib/ and then have your iwperl scripts that use the module start with something like:<pre>my $iwhome;
BEGIN{
use TeamSite::Config;
$iwhome = TeamSite::Config::iwgethome();
};
use lib "$iwhome/local/lib";
use XML::Writer;</pre>
It's been a while since I've had to do something like this, so the above may not be 100% correct.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
LooseCannon
John,
If you're not sold on using XML::Writer I suggest you take a look at
XML
OM
. A resource you might find useful is a
"Best Practice" document
that Interwoven wrote. It has a section(6.2.4) dedicated to DCR manip using XML:
OM.
gzevin
well, I wrote this when I was with IWOV..
By now I'd reccommend to use TeamSite:
CRnode
At the time I wrote it, the native API could not modify the XML, hence XML:
OM has been employed. Since 5.0, Jon ****'s API was substantially expanded, so I believe XML:
OM should be forgotten, unless you want to do some complex manipulations that make TeamSite:
CRnode unusable.
hm...I've just looked into the document, and it says 5.X versions.. Well, it took IWOV a while to publish the document (for external customers) that was written at least 1 year earlier
) It's still usable, though...
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
LooseCannon
I've never used or even read the perldoc on TeamSite:
CRnode because when it comes to touching XML I try to stay away from TeamSite specific modules. At the moment our shop is creating XML(DCR) via templates and skinning the content in TeamSite. But in the future we might only use TeamSite for storage and versioning. With that said the skinning process is more portable when using standard modules like XML:
OM or XSLT which is very cool.
PS Nice document Greg.
gzevin
well, then you could definitely use what I have written in that paper.
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Migrateduser
Are there any examples of writing entire DCRs based on other DCRs using this module?
Thanks,
-John
gzevin
no, I actually started using DCR::Node, when I had to do more complex tasks. But in that document there are a few examples on reading and writing DCRs....
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Migrateduser
I meant TeamSite:
CRnode - are there any complete examples of writing DCRs with this?
LooseCannon
I haven't seen any complete examples around, just the perldoc.
Migrateduser
It would be great if Interwoven could provide an example of using TeamSite:
CRnode to update DCRs with nested replicants. It sure seems like a disaster from here.
LooseCannon
I have some XML manip code that uses XML:
OM, if you're interested...
Migrateduser
Too late, I think I'm already committed here. If I bang my head against this module too much longer I'll ask you to send. Thanks.
LooseCannon
Ok, have fun
Johnny
Hey John,
check your email
John Cuiuli
Migrateduser
yeah yeah thanks
Hemant
John you can do the restructuring of DCRs using XML:
OM module.