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 (2016)
-> - Issue with Processing Instruct... (1)
-> + 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
Arthur GardnerSubject: What path notation works when in xQuery
Author: Arthur Gardner
Date: 08 Sep 2017 03:13 PM
Hi!

I'm running X16 Enterprise Suite 64-bit.

Suppose that $node is a variable representing a node in a document, and "Element1" is the name of a child element of that node.

In some contexts, I can say:

$node/Element1/text()

In other contexts, this returns nothing, but I can use:

$node/*:Element1/text()

What are the rules for these notations?

Postnext
Ivan PedruzziSubject: What path notation works when in xQuery
Author: Ivan Pedruzzi
Date: 08 Sep 2017 06:41 PM
Arthur,
Hi Arthur,

If the namespace wildcard matches your element is not in the default namespace.

To match a particular namespace you need to declare it, here an example, say you have the following XML input document which overrides the default namespace:

<root xmlns="foo:bar">
<element>Hello</element>
</root>

or in an equivalent form which uses namespace prefix "ns"

<ns:root xmlns:ns="foo:bar">
<ns:element>Hello</ns:element>
</ns:root>


Both documents are equivalent to XQuery

Here a query that works

declare namespace ns = "foo:bar";

/ns:root/ns:element


Does it help?


Ivan Pedruzzi
Stylus Studio Team

Postnext
Arthur GardnerSubject: What path notation works when in xQuery
Author: Arthur Gardner
Date: 11 Sep 2017 01:20 PM
Thanks!

It may well help, once I grasp it.

We are not explicitly using namespaces.

Here is my test:

declare variable $xPRSXMLInput as document-node() external;

let $doc := $xPRSXMLInput//bogus
let $options:= $doc/*:ManualUnderwriting/*:Quote/*:INST_Options
return
<Outer>
{
for $opt in $options/*[name() = 'Option']
return
let $covs := $opt/*[name() = 'Coverage']
let $cov := $covs[3]
(: let $pc := $cov/INST_CovType/text() :)
let $pc := $cov/*:INST_CovType/text()
return $pc
}
</Outer>

The input document starts like this:

<?xml version="1.0"?>
<distribution-request>
<distribution-package>
<distribution-item id="item1">

If the commented line of code is used in place of the following line, the result is <Outer/>. But as written, the Outer element contains a string of text from the input file.

Arthur

Postnext
Ivan PedruzziSubject: What path notation works when in xQuery
Author: Ivan Pedruzzi
Date: 11 Sep 2017 09:36 PM

before I reply please post a complete well-formed example of your input XML document.

Which XQuery processor you have selected in the scenario dialog, SAxon or DataDirect XQuery?


Ivan Pedruzzi
Stylus Studio Team

Postnext
Arthur GardnerSubject: What path notation works when in xQuery
Author: Arthur Gardner
Date: 14 Sep 2017 06:22 PM
Originally Posted: 14 Sep 2017 06:21 PM
Hi.

I am using DataDirect. If I choose Saxon, the xQuery runs forever, until I kill it with Task Manager. I'm developing on Windows 7 (64) and deploying to Linux.

I will attach the input file.

Thanks,
Arthur


UnknownBettMUW_SupLife_SupADD_SupDPND_STD_LTD_CostBen14.xml
Sample xml input

Posttop
Ivan PedruzziSubject: What path notation works when in xQuery
Author: Ivan Pedruzzi
Date: 14 Sep 2017 09:50 PM

As I stated, your input document overrides the default namespace so you need to define the namespace in the query

It happens here
<ManualUnderwriting xmlns="http://disl.pubdocs.muw.services.ins.us.metlife.com">

In addition most of your expression forced the xquery engine to navigate each node in the input document.

The following solution takes 20 milliseconds on both processors.

Make sure to bind the parameter $xPRSXMLInput to an expression like doc('file:///c:/myfile.xml')
in the scenario dialog.

declare namespace ml = "http://disl.pubdocs.muw.services.ins.us.metlife.com";

declare variable $xPRSXMLInput as document-node(element(*, xs:untyped)) external;

let $doc := $xPRSXMLInput/distribution-request/distribution-package/distribution-item/calligo-item/generation-data/plain-data/interactive/bogus
let $options:= $doc/ml:ManualUnderwriting/ml:Quote/ml:INST_Options
return
<Outer>
{
for $opt in $options/ml:Option
return
let $covs := $opt/ml:Coverage
let $cov := $covs[3]
let $pc := $cov/ml:INST_CovType/text()
return $pc
}
</Outer>


Ivan Pedruzzi
Stylus Studio Team

   
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.