XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Doug LundinSubject: Single row to multiple row transformation?
Author: Doug Lundin
Date: 28 Apr 2006 04:19 PM
Hello,

Being new to XQuery, what I am trying to do may be very simple but I don't even have the language to describe it. So, let me explain as concisely as I can. I believe my XQuery mapping is incorrect.

I would like to take three datapoints and, with an XQuery, map them into a new file with three datapoints. But, my XQuery is smashing all three datapoints into a single datapoint. (Data below)

Am I missing a function?

Thanks in advance!
Doug

Here are my data

XML input:
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table>
<tr>
<td>
<ul>
<li><span class="headline"><a href="http://biz.yahoo.com/bw/060201/20060201006257.html?.v=1">SonoSite
Schedules Fourth Quarter and Year-End Financial Release and
Announces Conference Call</a></span>
</li>
<li><span class="headline"><a href="http://biz.yahoo.com/bw/060201/20060201006254.html?.v=1">Sheila
Kelley's S Factor Launches in Encino,
California</a></span>
</li>
<li><span class="headline"><a href="http://biz.yahoo.com/bw/060201/20060201006252.html?.v=1">Pacific
Commerce Bank Announces Appointment of Brian H. Kelley as Chief
Executive Officer</a></span>
</li>
</ul>
</td>
</tr>
</table>
</body>
</html>


xquery:
declare namespace a = "http://www.w3.org/1999/xhtml";
<transform>
<content_url>
{data(/a:html/a:body/a:table/a:tr/a:td/a:ul/a:li/a:span/a:a/@href)}
</content_url>
</transform>


Results of this operation:
<transform>
<content_url>http://biz.yahoo.com/bw/060201/20060201006257.html?.v=1 http://biz.yahoo.com/bw/060201/20060201006254.html?.v=1 http://biz.yahoo.com/bw/060201/20060201006252.html?.v=1</content_url>
</transform>


I am trying to get:
<transform>
<content_url>http://biz.yahoo.com/bw/060201/20060201006257.html?.v=1</content_url>
<content_url>http://biz.yahoo.com/bw/060201/20060201006254.html?.v=1</content_url>
<content_url>http://biz.yahoo.com/bw/060201/20060201006252.html?.v=1</content_url>
</transform>

Postnext
(Deleted User) Subject: Single row to multiple row transformation?
Author: (Deleted User)
Date: 28 Apr 2006 05:00 PM
Hi Doug

You can try this...

declare namespace a = "http://www.w3.org/1999/xhtml";
<transform>
{
for $v in data(/a:html/a:body/a:table/a:tr/a:td/a:ul/a:li/a:span/a:a/@href)
return
<content_url>
{$v}
</content_url>
}
</transform>


Regards
Srini

You can find a quick primer on XQuery at http://www.stylusstudio.com/xquery_primer.html.

Posttop
Doug LundinSubject: Single row to multiple row transformation?
Author: Doug Lundin
Date: 28 Apr 2006 05:11 PM
That did it - thanks!

I'll work through the tutorials now

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.