473,721 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Marking words in a text

Hello

How should I go about marking certain words in a text? I've got a list of
words:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Mark.xsl" ?>
<Words>
<Word>
<Acronym>XML</Acronym>
<Description>eX tensible Markup Language</Description>
</Word>
<Word>
<Acronym>SGML </Acronym>
<Description>St andard Generalized Markup Language</Description>
</Word>
<Word>
<Acronym>ISO</Acronym>
<Description>In ternational Organization for Standardization </Description>
</Word>
</Words>

I want the words (acronyms) above to be marked within bold-tags in the text
below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"<xsl: output method="xml"
version="1.0" encoding="UTF-8" indent="yes"/ <xsl:template match="Words">
XML is a simple, very flexible text format derived from SGML (ISO 8879)
</xsl:template>
</xsl:stylesheet>

Can someone help me on my way? :-)
Jun 27 '08 #1
7 2182
Hvid Hat wrote:
I want the words (acronyms) above to be marked within bold-tags in the text
below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"<xsl: output method="xml"
version="1.0" encoding="UTF-8" indent="yes"/ <xsl:template match="Words">
XML is a simple, very flexible text format derived from SGML (ISO 8879)
</xsl:template>
</xsl:stylesheet>
That "text" is an XSLT stylesheet with output method="xml" so it is not
clear what you want to achieve? Do you want to take your acronym list
and transform it to HTML to be rendered in a browser?

That is possible with

<xsl:styleshe et
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0">

<xsl:output method="html" indent="yes"/>

<xsl:template match="Words">
<html lang="en">
<head>
<title>List of Acronymns</title>
<style tyype="text/css">
dt { font-weight: bold; }
</style>
</head>
<body>
<dl>
<xsl:apply-templates select="Word"/>
</dl>
</body>
</html>
</xsl:template>

<xsl:template match="Word">
<dt>
<xsl:value-of select="Acronym "/>
</dt>
<dd>
<xsl:value-of select="Descrip tion"/>
</dd>
</xsl:template>

</xsl:stylesheet>

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
Hvid Hat wrote:
Hello

How should I go about marking certain words in a text? I've got a list of
words:
If you mean you want to automate the application of markup to a
document, by matching each word against your list of acronyms, then it's
probably possible in XSLT (easier in XSLT2 than 1.0) but difficult when
you need to handle things like "in XML's model" where the "word" is not
delimited by spaces or markup boundaries. You'd have to use a recursive
template to isolate each word in turn and test it against your list,
which would be slow.

///Peter

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Mark.xsl" ?>
<Words>
<Word>
<Acronym>XML</Acronym>
<Description>eX tensible Markup Language</Description>
</Word>
<Word>
<Acronym>SGML </Acronym>
<Description>St andard Generalized Markup Language</Description>
</Word>
<Word>
<Acronym>ISO</Acronym>
<Description>In ternational Organization for Standardization </Description>
</Word>
</Words>

I want the words (acronyms) above to be marked within bold-tags in the text
below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"<xsl: output method="xml"
version="1.0" encoding="UTF-8" indent="yes"/ <xsl:template match="Words">
XML is a simple, very flexible text format derived from SGML (ISO 8879)
</xsl:template>
</xsl:stylesheet>

Can someone help me on my way? :-)
Jun 27 '08 #3
Peter Flynn wrote:
You'd have to use a recursive
template to isolate each word in turn and test it against your list,
which would be slow.
Or have the stylesheet invoke an extension function written in a
language better suited to this task.

Personally, I think you should make this the author's responsibility.
Maybe use the (slow) find-words-and-tag-them as an authoring tool to
help them do so... but encourage them to use appropriate markup in the
first place rather than trying to reverse-engineer their text.
Jun 27 '08 #4
On 11-04-2008 21:12:48, Peter Flynn wrote:
If you mean you want to automate the application of markup to a
document, by matching each word against your list of acronyms, then it's
probably possible in XSLT (easier in XSLT2 than 1.0) but difficult when
you need to handle things like "in XML's model" where the "word" is not
delimited by spaces or markup boundaries. You'd have to use a recursive
template to isolate each word in turn and test it against your list,
which would be slow.
I'm just playing around with XSLT to improve my skills so the performance is
not important. I'll give it a try but if anyone can help me on my way, I'd be
appreciated :-)

What if I wanted to mark up relating words in some text? Say I wanted to mark
up countries consiting of more words, e.g. Faroe Islands, South Africa, New
Zealand etc. Then I couldn't isolate each word in the text and make a
comparision. Would I have to use a mix of contains, substring-before,
substring-after?
Jun 27 '08 #5
On 11-04-2008 23:15:56, "Joseph J. Kesselman" wrote:
Peter Flynn wrote:
Or have the stylesheet invoke an extension function written in a
language better suited to this task.
I've written a few small extension functions in C#. I thought about writing
an extension function to solve the problem. Any ideas on how to approach the
problem. Create a comma-separated list of the words and pass the word list
and the text to an extension function and have the function mark up the words
and return the marked up text? Is it possible to access the XML containing
the words from the extension function so I could make a List<stringwith in
my extension function? Perhaps send the XML containing the words as a node
set or something. Does it make sense? :-)
Personally, I think you should make this the author's responsibility.
Maybe use the (slow) find-words-and-tag-them as an authoring tool to
help them do so... but encourage them to use appropriate markup in the
first place rather than trying to reverse-engineer their text.
I agree. I would make it an authoring tool but currently I'm just playing
around with XSLT to improve my skills.

Jun 27 '08 #6
Hvid Hat wrote:
What if I wanted to mark up relating words in some text?
This is a programming problem first, then an XSLT problem. Figure out
how you would solve it in any other programming language, so you have
the problem well-formed and well-understood. Then figure out how to
solve it nonprocedurally . Then implement that in XSLT... or decide not
to do so, if it really isn't a problem well-suited to XSLT (as this may
not be.)
Jun 27 '08 #7
Hvid Hat wrote:
On 11-04-2008 21:12:48, Peter Flynn wrote:
>If you mean you want to automate the application of markup to a
document, by matching each word against your list of acronyms, then it's
probably possible in XSLT (easier in XSLT2 than 1.0) but difficult when
you need to handle things like "in XML's model" where the "word" is not
delimited by spaces or markup boundaries. You'd have to use a recursive
template to isolate each word in turn and test it against your list,
which would be slow.

I'm just playing around with XSLT to improve my skills so the performance is
not important. I'll give it a try but if anyone can help me on my way, I'd be
appreciated :-)

What if I wanted to mark up relating words in some text? Say I wanted to mark
up countries consiting of more words, e.g. Faroe Islands, South Africa, New
Zealand etc. Then I couldn't isolate each word in the text and make a
comparision. Would I have to use a mix of contains, substring-before,
substring-after?
No, you'd pay someone to open the document in an XML editor and do it by
hand.

Really. If you want to apply reliable content markup on names (people,
places, things), it's a *human* task.

///Peter
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2433
by: denisb | last post by:
hello all, for a search engine, I'm looking for a regexp than can do the job it is just (!) a 's' problem (frequent in french) : I have a field 'thesaurus' in a table MySQL (3.23.56) ; I have a field 'search' in a form where user can input a word ; what I want is :
9
2138
by: superprad | last post by:
"X-No-Archive: yes" what I am looking for is 1. To create a list of different words of various lengths(1-15) using A-Z,a-z,0-9 and punctuations.Basically anything that could be found on a text document. 2. The words formed need not be meaningful .FOr example 'ajf' or 'fcjgdtfhbs' or even 'gfdew!' or '#bang.' would be a valid entry in the
2
4688
by: CV | last post by:
How can I match 'n' number of neighbouring words of a pattern using regular expressions? For example, suppose I am looking for the pattern "length xyz cm" in some text. where xyz is a number - integer or fraction or decimal point. How can I also grab about 3-5 words on either side of the pattern "length xyz cm"? The surrounding words are not always constant & may be variable. Also, the original text to be matched is not just a single...
9
2994
by: Gary | last post by:
Hello, Is it possible to dynamically update a textbox with words chosen from a list using form checkboxes and javascript? Gary
3
1924
by: Spartanicus | last post by:
How to get help from this group, and how to construct a minimised test case: http://www.spartanicus.utvinternet.ie/help_us_help_you.htm -- Spartanicus
7
5460
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words <http://www.sai.msu.su/%7Emegera/oddmuse/index.cgi/Tsearch_V2_compound_words> I used the german myspell dictionary from http://lingucomponent.openoffice.org/spell_dic.html and converted it with my2ispell
10
3905
by: Johny | last post by:
I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too)
0
2700
by: Nokao | last post by:
I'm having a lot of severe errors in my db2diag.log, (DB2 v9.1.0.0). Googling I don't fin any information :( What can I do? I attach the first reports...: 2007-11-19-17.50.26.379948+060 I1388E497 LEVEL: Severe PID : 7097 TID : 47556548689552PROC : db2agent (MYDATABASE) INSTANCE: db2inst1 NODE : 000 DB : MYDATABASE
1
525
by: Hvid Hat | last post by:
Hello How should I go about marking certain words in a text? I've got a list of words: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Mark.xsl"?> <Words> <Word> <Acronym>XML</Acronym>
2
3415
by: alwaali | last post by:
Hi I need help please This is my project and i need a help to solve it with you A page of text is to be read and analyzed to determine number of occurrences and locations of different words. The results of the analysis are to be stored in a suitable data structure. The main task in this project is to design a suitable ADT (call it WAnalysis) to store the results and enable the following operations to be performed as fast as possible:...
0
8730
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9064
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4753
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.