You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ja...@apache.org on 2004/06/21 08:36:20 UTC

svn commit: rev 21526 - in xml/xerces-p/trunk: . docs hints samples

Author: jasons
Date: Sun Jun 20 23:36:19 2004
New Revision: 21526

Added:
   xml/xerces-p/trunk/hints/mswin32.pl
   xml/xerces-p/trunk/samples/XMLSimple.pm
Modified:
   xml/xerces-p/trunk/MANIFEST
   xml/xerces-p/trunk/Makefile.PL
   xml/xerces-p/trunk/docs/readme.xml
Log:
back-ported from 2.5

Modified: xml/xerces-p/trunk/MANIFEST
==============================================================================
--- xml/xerces-p/trunk/MANIFEST	(original)
+++ xml/xerces-p/trunk/MANIFEST	Sun Jun 20 23:36:19 2004
@@ -26,6 +26,7 @@
 hints/solaris_2.pl
 hints/aix.pl
 hints/hpux.pl
+hints/mswin32.pl
 
 # user level documents
 Changes
@@ -52,6 +53,7 @@
 
 # sample programs
 samples/validator.pl
+samples/XMLSimple.pm
 samples/DOM2hash.pl
 samples/EnumVal.pl
 samples/SEnumVal.pl

Modified: xml/xerces-p/trunk/Makefile.PL
==============================================================================
--- xml/xerces-p/trunk/Makefile.PL	(original)
+++ xml/xerces-p/trunk/Makefile.PL	Sun Jun 20 23:36:19 2004
@@ -247,20 +247,6 @@
 my @MACRO;
 $CFLAGS .= '-D_REENTRANT';
 
-if ($^O eq 'MSWin32') {
-# the following info helpful reported by Martin Raspe:
-# From: "Martin Raspe" <ra...@uni-trier.de>
-# Subject: XML::Xerces-2.3.0-0 on Windows
-# To: xerces-p-dev@xml.apache.org
-# Date: Thu, 12 Jun 2003 14:34:02 +0200
-# --
-# Without "-DHAS_BOOL" a lot of "unresolved external ..." linker errors
-# are produced. -TP forces C++ compilation (not needed if the file is
-# named *.cpp), -GX is asked for by the compiler.
-
-  $CFLAGS .= " -DHAS_BOOL -TP -GX";
-}
-
 # we only consider using SWIG if we are a Xerces Developer
 if ($XERCES_DEVEL) {
   # replace this with the path to your Unix compatible find application
@@ -290,6 +276,13 @@
       die 'unsupported compiler';
     }
     my $SWIG_ARGS = qq[-Wall $OS_DEF $CC_DEF -DXERCES_VERSION="$XERCES_PERL_VERSION" \$(INC) -perl5 -c++ -shadow];
+
+    my $MAKE = '	\$(MAKE) -C Handler static';
+    if ($^O eq 'MSWin32') {
+      # nmake doesn't not honor '-C'
+      $MAKE =  '	cd Handler && \$(MAKE) static';
+    }
+
     my $retval = <<TERMINUS;
 Xerces.cpp: Xerces.i typemaps.i @header_files postSource.pl 
 	\$(SWIG) $SWIG_ARGS -o Xerces.cpp Xerces.i
@@ -306,7 +299,7 @@
 	fi
 
 $HANDLER_LIB:
-	\$(MAKE) -C Handler static
+$MAKE
 TERMINUS
     return $retval;
   }

Modified: xml/xerces-p/trunk/docs/readme.xml
==============================================================================
--- xml/xerces-p/trunk/docs/readme.xml	(original)
+++ xml/xerces-p/trunk/docs/readme.xml	Sun Jun 20 23:36:19 2004
@@ -37,6 +37,10 @@
 anchor='perl-api'>Special Perl API Features</link> section).
     </p>
   </s2>
+  <s2 title="Support">
+    <p>The online users mailing list is the place for any
+    questions. It is at: &XERCES_P_LIST;</p>
+  </s2>
   <s2 title="Available Platforms">
     <p>
 The code has been tested on the following platforms: 

Added: xml/xerces-p/trunk/hints/mswin32.pl
==============================================================================
--- (empty file)
+++ xml/xerces-p/trunk/hints/mswin32.pl	Sun Jun 20 23:36:19 2004
@@ -0,0 +1,13 @@
+# the following info helpful reported by Martin Raspe:
+# From: "Martin Raspe" <ra...@uni-trier.de>
+# Subject: XML::Xerces-2.3.0-0 on Windows
+# To: xerces-p-dev@xml.apache.org
+# Date: Thu, 12 Jun 2003 14:34:02 +0200
+# --
+# Without "-DHAS_BOOL" a lot of "unresolved external ..." linker errors
+# are produced. -TP forces C++ compilation (not needed if the file is
+# named *.cpp), -GX is asked for by the compiler.
+
+use Config;
+
+$self->{CCFLAGS} .= " $Config::Config{cppflags} -DHAS_BOOL -TP -GX";

Added: xml/xerces-p/trunk/samples/XMLSimple.pm
==============================================================================
--- (empty file)
+++ xml/xerces-p/trunk/samples/XMLSimple.pm	Sun Jun 20 23:36:19 2004
@@ -0,0 +1,74 @@
+package XML::Xerces::XMLSimple;
+
+# From: Brian Faull <bf...@mitre.org>
+# Subject: Re: XML::Simple in Xerces (was Re: Xerces-perl for Win32)
+# To: "Jason E. Stewart" <ja...@openinformatics.com>
+# CC: xerces-p-dev@xml.apache.org
+# Date: Tue, 11 Nov 2003 23:29:26 -0500
+
+# Construct the ridiculous data structure used by XML::Simple
+# Each node (except toplevel!) is an arrayref.
+# For text nodes, the hashref in the first element of the arrayref includes a key
+#   'content' whose value is an arrayref of all of the text nodes within parent node.
+# For attributes of a node, the first element of the arrayref includes a key having
+#   the same name as the attribute name, and the value is an arrayref. If there exists
+#   one or more child nodes with the same name as an attribute name, the first element
+#   of the arrayref is the value of the attribute, and the remaining elements are
+#   hashrefs containing one key 'content' whose value is the enclosed text.
+# For children of the node, there is a key that points to an arrayref, as above.
+# If there is more than one node of the same type, these are represented as individual
+#   hashrefs within the enclosing arrayref.
+# This is perhaps an oversimplification. Further information in XML::Simple
+
+sub node2hash {
+  my $node = shift;
+  my $return = [{}];
+
+  # build a hashref that represents the attributes of this element
+  my $nodename = $node->getNodeName();
+  if ($node->hasAttributes()) {
+    my %attrs = $node->getAttributes();
+    foreach my $attr (keys %attrs) {
+      $return->[0]->{$attr} = $attrs{$attr};
+    }
+  }
+
+  # recursively create structures for child nodes...
+  # sorry, this gets kinda ugly...
+  if ($node->hasChildNodes()) {
+    my @text = ();
+    foreach my $child ($node->getChildNodes()) {
+      my $childname = $child->getNodeName();
+      if ($child->isa('XML::Xerces::DOMElement')) {
+        if (exists $return->[0]->{$childname}) {
+          if (UNIVERSAL::isa($return->[0]->{$childname}, 'ARRAY')) {
+            push @{$return->[0]->{$childname}}, node2hash($child)->[0];
+          }
+          else {
+            $return->[0]->{$childname} = [$return->[0]->{$childname}, node2hash($child)->[0]];
+          }
+        }
+        else { $return->[0]->{$childname} = node2hash($child); }
+      }
+      elsif ($child->isa('XML::Xerces::DOMText')) {
+        my $val = $child->getNodeValue();
+        push @text, $val
+          if $val =~ m/\S+/;
+      }
+    }
+
+    # Add text nodes as key 'content'
+    if (exists $return->[0]->{'content'}) {
+      if (UNIVERSAL::isa($return->[0]->{'content'}, 'ARRAY')) {
+        unshift @{$return->[0]->{'content'}}, @text;
+      }
+      else { warn "content element should be array"; }
+    }
+    else {
+      if (scalar @text == 1) { $return->[0]->{'content'} = $text[0]; }
+      if (scalar @text >  1) { $return->[0]->{'content'} = \@text; }
+    }
+  }
+  return $return;
+}
+

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org