summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhansp <hansp>2001-07-13 23:24:34 +0000
committerhansp <hansp>2001-07-13 23:24:34 +0000
commit59c48ffbc0c177bfad69aa17107a7e198e9f1a28 (patch)
treea01f01f9f8d54e380a7063aeff00811825129583
parent00709516117b9531f4cccb14e9597e8a88f01334 (diff)
2001-07-13 Hans Petter Jansson <hpj@ximian.com>
* xml.pl.in (xst_xml_model_get_pcdata): Implement. (xst_xml_model_set_pcdata): Implement. (xst_xml_model_get_attribute): Implement. (xst_xml_model_set_attribute): Implement.
-rw-r--r--ChangeLog9
-rw-r--r--parse.pl.in4
-rwxr-xr-xtest.pl5
-rw-r--r--xml.pl.in43
4 files changed, 55 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index b1bcdd0..bfac905 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,15 @@
2001-07-13 Hans Petter Jansson <hpj@ximian.com>
+ * xml.pl.in (xst_xml_model_get_pcdata): Implement.
+ (xst_xml_model_set_pcdata): Implement.
+ (xst_xml_model_get_attribute): Implement.
+ (xst_xml_model_set_attribute): Implement.
+
+2001-07-13 Hans Petter Jansson <hpj@ximian.com>
+
* xml.pl.in (xst_xml_model_add): Implement.
(xst_xml_model_ensure): Implement.
- (xst_xml_model_remove): Implement.
+ (xst_xml_model_remove): Implement.
2001-07-13 Tambet Ingo <tambet@ximian.com>
diff --git a/parse.pl.in b/parse.pl.in
index 6766631..4a49d9c 100644
--- a/parse.pl.in
+++ b/parse.pl.in
@@ -1307,8 +1307,8 @@ sub xst_parse_xml
if ($branch)
{
- return &xst_xml_get_attribute ($branch, $property) if $property ne "";
- return &xst_xml_get_pcdata ($branch);
+ return &xst_xml_model_get_attribute ($branch, $property) if $property ne "";
+ return &xst_xml_model_get_pcdata ($branch);
}
return undef;
diff --git a/test.pl b/test.pl
index faa49c4..d27295c 100755
--- a/test.pl
+++ b/test.pl
@@ -100,8 +100,9 @@ sub test_interfaces
# &xst_debug_print_struct ($tree);
$model = &xst_xml_model_scan ("/etc/alchemist/namespace/printconf/local.adl");
-&xst_xml_model_ensure ($model, "/adm_context/datatree/printconf/print_queues/lpnew/faan/pekk/fette/");
-&xst_xml_model_remove ($model, "/adm_context/datatree/printconf/print_queues/", "lpekk");
+$branch = &xst_xml_model_find ($model, "/adm_context/datatree/");
+&xst_xml_model_set_pcdata ($branch, "FAAN");
+&xst_xml_model_set_attribute ($branch, "Jern", "Jepp");
print &xst_xml_model_print ($model);
# print &xst_parse_xml ("/etc/alchemist/namespace/printconf/local.adl",
diff --git a/xml.pl.in b/xml.pl.in
index 4b25c6a..4dd7023 100644
--- a/xml.pl.in
+++ b/xml.pl.in
@@ -784,7 +784,7 @@ sub xst_xml_model_ensure
sub xst_xml_model_remove
{
my ($model, $varpath, $tag) = @_;
- my ($branch);
+ my ($branch, $i);
@path = split /\//, $addpath;
$branch = &xst_xml_model_find ($model, $varpath);
@@ -805,4 +805,45 @@ sub xst_xml_model_remove
return -1;
}
+sub xst_xml_model_get_pcdata
+{
+ my ($branch) = @_;
+ my ($i);
+
+ for ($i = 1; $i < @$branch; $i += 2)
+ {
+ if ($$branch [$i] == 0)
+ {
+ my $retval = &xst_xml_unquote ($$branch [$i + 1]);
+ return ($retval);
+ }
+ }
+
+ return "";
+}
+
+sub xst_xml_model_set_pcdata
+{
+ my ($branch, $pcdata) = @_;
+
+ @$branch = (@$branch [0]);
+
+ $$branch [1] = 0;
+ $$branch [2] = &xst_xml_quote ($pcdata);
+}
+
+sub xst_xml_model_get_attribute
+{
+ my ($branch, $attr) = @_;
+
+ return $$branch[0]->{$attr};
+}
+
+sub xst_xml_model_set_attribute
+{
+ my ($branch, $attr, $value) = @_;
+
+ return $$branch[0]->{$attr} = $value;
+}
+
1;