Altova Mailing List Archives


Re: Escapes Sequences Not Working?

From: William Park <opengeometry@-----.-->
To: NULL
Date: 8/26/2004 8:37:00 PM
In <comp.text.xml> Rick Brandt <rickbrandt2@h...> wrote:
> I guess I will look at collecting the pieces in characters and not
> writing them until endElement().  I just wish I could fix the CDATA
> bug as this was working fine for 3 or 4 years before that started
> happening.  Either CDATA forces all of the text in the characters
> event to be pulled in a single block or we just got really lucky for
> all that time because I never saw any truncation until the CDATA
> section was removed.

You were just lucky.  :-)   

If you're using (or can use) Bash shell, then collecting all texts
inside <Notes> or any other element is simple.  Assuming elements
containing data are not nested,

    start () {		# Usage: start tag att=value ...
	case $1 in 
	    Notes) unset data;;
	esac
    }
    middle () {		# Usage: middle text
	case ${XML_ELEMENT_STACK[1]} in
	    Notes) data+="$1" ;;
	esac
    }
    end () {		# Usage: start tag
	case $1 in 
	    Notes) echo "$data" ;;
	esac
    }

Then,
    xml -s start -d middle -e end "<Notes>aa&amp;bb</Notes>"
produces
    aa&bb

Ref:
    http://freshmeat.net/projects/bashdiff/
    http://home.eol.ca/~parkw/index.html#xml
    help xml
-- 
William Park <opengeometry@y...>
Open Geometry Consulting, Toronto, Canada

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.