ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: [ANNOUNCE] XML::Filter::Glossary 0.1
by Ken MacLeod other posts by this author
Sep 10 2002 3:27PM messages near this date
view in the new Beta List Site
Re: source-provided xslt if logic? | Re: [ANNOUNCE] XML::Filter::Glossary 0.1
Aaron Straup Cope <asc@[...].net>  writes:

>  http://search.cpan.org/author/ASCOPE/XML-Filter-Glossary-0.1
>  
>  "This package is modelled after the UserLand glossary system where
>  words, or phrases, wrapped in double-quotes are compared against a
>  lookup table and are replaced by their corresponding entries.

>  "Keywords are flagged as being any word, or words, between double
>  quotes which are then looked up in the glossary. If no match is
>  found, the text is left unaltered.

The UserLand glossary system is well known for catching
false-positives -- matching words the user didn't know were in the
glossary.

One often suggested alternative is to use a glossary-namespaced XML
element in place of the plain text and then use empty (or not??)
glossary elements to call out glossary items:

  $glossary-> set_glossary("/usr/home/asc/bookmarks.xbel");
  $parser-> parse_string("<?xml version = '1.0' ?><root xmlns:g="http://aaronland.net/glossar
y"> This is <g:aaronland/></root>");

  # prints :

  <?xml version = "1.0" ?> 
  <root> 
   This is <a href='http://www.aaronland.net'> aaronland</a>
  </root> 

In the start_element() of XML::Filter::Glossary, you can then do:

  if ($element-> {NamespaceURI} == 'http://aaronland.net/glossary') {
    # merge content based on $element-> {LocalName} as the key
  }

Probably much simpler and far more foolproof.

For user-entry boxes, like posting and comment textinputs, you can
"presupply" the xmlns:g attribute in the wrapper for their entered
text (if xml) or do a literal search for <g:WORD/>  and handle
appropriately.  For users who are aware of the glossary, <g:WORD/>  is
no difference, for users unaware they can never get hit by the
glossary by accident.

  -- Ken
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Ken MacLeod
Bart Schuller
Aaron Straup Cope

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved