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

Home Posts Topics Members FAQ

Query with subelements inside words

Here is a sample of the kind of XML I'm working with:

<root>
<elemt>Somethin g is ro<lig>tt</lig>en in the state of
<emph>Den</emph>mark</elemt>
</root>

I would like to be able to extract the contents of <elemt> as a string
without the subelements and with the integrity of the words
unaffected...fo r example:

<result>
Something is rotten in the state of Denmark
</result>

I have tried various approaches with XQuery along the lines of...

for $TheResult in (/root/elemt) return normalize-space($TheResul t)

....but the best I've been able to do is this:

<result>
Something is ro tt en in the state of Den mark
</result>

As you can see, spaces are being inserted in undesirable locations.

Any ideas as to how I can make this work in XQuery?

thanks
Diz.

Jul 20 '05 #1
1 1088
Problem solved.

My XQuery implementation was/is buggy. Saxon returns the correct result
if fed

fn:string(/root/elemt)

regards,
Diz.

di*******@gmail .com wrote:
Here is a sample of the kind of XML I'm working with:

<root>
<elemt>Somethin g is ro<lig>tt</lig>en in the state of
<emph>Den</emph>mark</elemt>
</root>

I would like to be able to extract the contents of <elemt> as a string
without the subelements and with the integrity of the words
unaffected...fo r example:

<result>
Something is rotten in the state of Denmark
</result>

I have tried various approaches with XQuery along the lines of...

for $TheResult in (/root/elemt) return normalize-space($TheResul t)

...but the best I've been able to do is this:

<result>
Something is ro tt en in the state of Den mark
</result>

As you can see, spaces are being inserted in undesirable locations.

Any ideas as to how I can make this work in XQuery?

thanks
Diz.


Jul 20 '05 #2

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

Similar topics

13
2888
by: dogu | last post by:
Noob alert. Code is below. File is saved as a .php. What I'm trying to do: User uses 'select' box drop down list to pick a value. Value ($site) is derived from a db query. This works fine. Value selected is used as the 'where' clause of the 2nd query. If $site is a single word, the 2nd query works like a charm. If $site is more than one word (has spaces), the query returns a null
2
926
by: Stan | last post by:
Hello all, I'm looking for some hints as to how to use the results of a query in another query. I assume I'm 'thinking' wrong in how to solve this, so I'm hoping someone can clobber me and send me in the right direction. My question is best illustrated by simplified example. I have one table (table A) with a single column called "Word". This table contains 100 records of single words. Another table (table B) contains whole sentences...
22
3049
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20 3, NULL, 9, 82, 25
2
1534
by: thomas | last post by:
Hello all Im having problems with selecting subelements from a dynamic created RTF converted to a node-set: i have hardcodet this example: the xml structure: <xsl:variable name="test">
1
5207
by: Novice | last post by:
Hi all, I'm having some trouble with a XPath query I would like to make I have the following simplified XML <A><B><C name="Test"></C><C name="Test2"></C></B><B><C name="Test"></C></B></A I would like to return all B elements that have a C sub-element that have a name with a particular value For example - I would like to retrieve all B elements that have a C sub-element with a name of Test. This should return 2 B elements. Likewise,...
0
937
by: Daniel Jorge | last post by:
Hi there, I'm in need to create a WebControl with subelements, just like ListBox, DropDownlList and stuff. But, of course, it's myh custom Item and not a ListItem control. The final result should be like this one (HTML / Design-time) <myNamespace:myControl id="myControl"> <myNamespace:myItem property1="teste" property2="teste1" ></myItem> <myNamespace:myItem property1="teste" property2="teste2" ></myItem>
2
4838
by: felecha | last post by:
Puzzled - I have a fairly simple query against an Access database that wants to eliminate the records in the table where the DeviceType is either MasterStation1 or MasterStation2 or .... in other words, I want the records that do not involve the Master Stations in our system. So, I expect to just write Select * from Device where DeviceType not LIKE '*MasterStation*'
3
2201
by: Wired Hosting News | last post by:
Lets say I have 10 products in 10 different stores and every week I get a report from each store telling me how many items they have left for each of the 10 products. So each week I enter in 100 records with a store number, item number, on hand qty, and date of report into my sales data table. My tables primary is a combo of store# & Item number & Date After 10 week of this I have 1000 record total with ten unique dates.
5
3528
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed to 1800 stores of a national home improvement chain store. Every week I electronicaly receive an excel spreadsheet "inventory report" with 19,800 rows or records, which I import into my tblSalesData table. The table now has 10 weeks of data or...
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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
8007
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
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
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.