pathed newlisp work in this for the time being.
But please teach it because this revision method does not understand whether it is a right method for newlisp.
(translated by http://honyaku.yahoo.co.jp/transtext)
Code: Select all
---- example.xml ----
<?xml version="1.0" ?>
<DATABASE name="example.xml">
<!--This is a database of fruits-->
    <果物>
        <名前>リンゴ - apple</名前>
        <色>赤 - red</色>
        <価格>0.80</価格>
    </果物>
    <果物>
        <名前>オレンジ - orange</名前>
        <色>オレンジ - orange</色>
        <価格>1.00</価格>
    </果物>
    <果物>
       <名前>バナナ - banana</名前>
       <色>黄色 - yellow</色>
       <価格>0.60</価格>
    </果物>
</DATABASE>
---- example.xml ----
---- after patched ----
(first (xml-parse (read-file "example.xml") (+ 1 2)))
("ELEMENT" "DATABASE" (("name" "example.xml")) (("COMMENT" "This is a database of fruits") 
  ("ELEMENT" "果物FRUIT" (("ELEMENT" "名前" (("TEXT" "リンゴ - apple"))) (
     "ELEMENT" "色" 
     (("TEXT" "赤 - red"))) 
    ("ELEMENT" "価格" (("TEXT" "0.80"))))) 
  ("ELEMENT" "果物FRUIT" (("ELEMENT" "名前" (("TEXT" "オレンジ - orange"))) 
    ("ELEMENT" "色" (("TEXT" "オレンジ - orange"))) 
    ("ELEMENT" "価格" (("TEXT" "1.00"))))) 
  ("ELEMENT" "果物FRUIT" (("ELEMENT" "名前" (("TEXT" "バナナ - banana"))) 
    ("ELEMENT" "色" (("TEXT" "黄色 - yellow"))) 
    ("ELEMENT" "価格" (("TEXT" "0.60")))))))
---- after patched ----
$ diff -crN nl-xml.c.org nl-xml.c
*** nl-xml.c.org        Mon Nov 23 02:45:16 2009
--- nl-xml.c    Fri Feb 26 16:59:46 2010
***************
*** 441,451 ****
  
  ++source; /* skip '/' */
  
! while(*source <= ' ' && source < endSrc) ++source; /* skip whitespace */
  
  tagStart = source;
  tagLen = 0;
! while(*source > ' ' && source < endSrc) ++source, ++tagLen; /* find tag end */
  
  attributes = parseAttributes(endSrc);
  if(optionsFlag & OPTION_SXML_ATTRIBUTES)
--- 441,451 ----
  
  ++source; /* skip '/' */
  
! while((unsigned char)*source <= ' ' && source < endSrc) ++source; /* skip whitespace */
  
  tagStart = source;
  tagLen = 0;
! while((unsigned char)*source > ' ' && source < endSrc) ++source, ++tagLen; /* find tag end */
  
  attributes = parseAttributes(endSrc);
  if(optionsFlag & OPTION_SXML_ATTRIBUTES)
***************
*** 519,530 ****
  
  while(!xmlError && source < endSrc)
        {
!       while(*source <= ' ' && source < endSrc) source++; /* strip leading space */
        namePos = source;
        nameLen = 0;
!       while(*source > ' ' && *source != '=' && source < endSrc) source++, nameLen++; /* get end */
        if(nameLen == 0) break;
!       while(*source <= ' ' && source < endSrc) source++; /* strip leading space */
        if(*source != '=')
                {
                xmlError = "expected '=' in attributes";
--- 519,530 ----
  
  while(!xmlError && source < endSrc)
        {
!       while((unsigned char)*source <= ' ' && source < endSrc) source++; /* strip leading space */
        namePos = source;
        nameLen = 0;
!       while((unsigned char)*source > ' ' && *source != '=' && source < endSrc) source++, nameLen++; /* get end */
        if(nameLen == 0) break;
!       while((unsigned char)*source <= ' ' && source < endSrc) source++; /* strip leading space */
        if(*source != '=')
                {
                xmlError = "expected '=' in attributes";
***************
*** 532,538 ****
                return nilCell;
                }
        else source++;
!       while(*source <= ' ' && source < endSrc) source++; /* strip spaces */
        if(*source != '\"' && *source != '\'')
                {
                xmlError = "attribute values must be delimited by \" or \' ";
--- 532,538 ----
                return nilCell;
                }
        else source++;
!       while((unsigned char)*source <= ' ' && source < endSrc) source++; /* strip spaces */
        if(*source != '\"' && *source != '\'')
                {
                xmlError = "attribute values must be delimited by \" or \' ";