OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] XML parsing the only way?

[ Lists Home | Date Index | Thread Index ]

> > 
> > The quickest code for doing this is to write a loop through 
> > the string,
>
> I see from this and your post on xsl-list that you're a man who likes
> low-level coding.
>

No, Michael, it is not so. I am just trying to match the level of coding
to the level of the problem. And, regarding the xsl-list post, I am not 
asking for lower-level coding; in fact, I think that coding with
perl|python|ruby would be higher-level and more natural than with
XSLT 2.0.

> What's wrong with:
>
> (char)Integer.parseInt(Pattern.compile("&#([0-9]+);").matcher(bunch).gro
> up(1));
>

don't get me wrong, I am not trying to compete. But:

1) it only works with Java 1.4+. I simply don't have it installed on
any of my computers because they are slow and it takes twice as much
time to launch as 1.3.

2) it only returns the first character. The OP asked to convert a bunch
to a string. 

3) it does not handle literal character in the input. The code below does.

If you add all these things to the single line above, you'll get as much
code, only slower and running on fewer platforms.

> Also untested.
>
> OK, add a couple more lines to do hex as well (but the OP didn't ask for
> that).

The code that just retrieves the first decimal character entity from a string
without regexps is as short as the line above. I've just tried to provide
a solution that would work.

Besides, I was just reacting the idea to use DOMDoc for that purpose.

David Tolpin
http://davidashen.net/




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS