in reply to Pulling out sections of an XMI file with XML::Twig
Is not $section what you want as a starting point?
sub uml_class { my ( $twig, $section ) = @_; $section->print (); }
Prints:
<UML:Class name="EARootClass" xmi.id="EAID_..."/><UML:Class name="Data +Type" xmi.id="EAID..."><UML:Classifier.feature xmi.id="EAID..."> <!-- I want to pull out the following UML:Attribute blocks --> <UML:Attribute name="dataTypeId"></UML +:Attribute><UML:Attribute name="name"></UML:Attribute></UML:Classifie +r.feature></UML:Class>
Update:
Note the "Processing just parts of an XML document" section in the XML::Twig documentation that describes twig_roots and in particular the line my( $t, $elt)= @_; in the sample code in that section.
Update:
and to reparse the sub-element:
sub uml_class { my ( $twig, $section ) = @_; my $xml = $section->sprint (); my $subTwig = XML::Twig->new ( twig_roots => { 'uml:attribute' => +\¨_attr}); $subTwig->parse ($xml); } sub uml_attr { my ($twig, $elt) = @_; $elt->print (); print "\n"; }
Prints:
<uml:attribute name="datatypeid"></uml:attribute> <uml:attribute name="name"></uml:attribute>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pulling out sections of an XMI file with XML::Twig
by bobf (Monsignor) on Sep 27, 2006 at 23:04 UTC | |
by mirod (Canon) on Sep 28, 2006 at 09:42 UTC | |
by bobf (Monsignor) on Sep 28, 2006 at 16:00 UTC | |
by mirod (Canon) on Sep 28, 2006 at 16:52 UTC | |
by bobf (Monsignor) on Sep 28, 2006 at 17:32 UTC |