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)
- Stylus Studio FAQs (159)
-> + Windows Installer (Not Respond... (2)
-> - system property org.xml.sax.dr... (1)
-> - Demonstration of CSV to Fixed-... (1)
-> - The Java Virtual Machine is re... (1)
-> - JDBC Users Guide (1)
-> - Connect for SQL/XML Questions (1)
-> - struzzo.exe has 10-25% cpu usa... (1)
-> - 'crossgrade' with SSL? (1)
-> + what happens with xmlspy licen... (3)
-> + crossgrade cheaper then update... (2)
-> + New to XML (2)
-> - Version 6 - price increase (1)
-> + XSD documentation (2)
-> + New Tutorial: How to Configure... (2)
-> + In dtd, Group comes first (2)
-> + converting DTD to Schema (3)
-> - New FAQ for Stylus Studio Home... (1)
-> + Project - Add New Document - a... (6)
-> + XSLT - Mapper view - And Or (2)
-> + Use XSD to produce sample XML... (2)
-> + Port to MAC OS X (2)
-> + First-time running froze! :( (2)
-> + how to register stylus studio ... (5)
-> + Wrapped Lines (3)
-> + CSV to XML Conversion (2)
-> - Xquery ques. How to check for ... (2)
-> ->Re: Xquery ques. How to c...
-> + XQUERY default views (3)
-> + DB to XML Data Conversion issu... (2)
-> - Rendering XForms with XSLT-sty... (1)
-> + Multiple XSDs to XML (2)
-> + Tables in WISIWYG (2)
-> + Does Stylus Studio provide API... (2)
-> + xlink (2)
-> + Tags in WYSIWYG (2)
-> + Removing spaces from XSLT Sour... (2)
-> + SS capabilities (3)
-> + Stylus Studio 3.1 in Windows X... (2)
-> + Macros and API (2)
-> + Stylus Studio FO support (2)
-> + XPath parser hangs stylus stud... (3)
-> + Stylus studio api (4)
-> + xsl files (2)
-> + SS4: user interface question (6)
-> + SS4: primitive advertising in ... (6)
-> + SenseX - howto insert default ... (2)
-> + search utility on Stylus Studi... (2)
-> + Javascript De-bugging (10)
-> + 'Promo' version of Beta 4.0 (4)
-> - 4.0 Beta now available! (1)
-> + XSL-FO editing (6)
-> + Re: Promo Version (9)
-> + xml->pdf (7)
-> + Functions handle in loops (2)
-> + DTD-Schema Conversion (4)
-> + Word Wrap? (2)
-> + Javascript extensions (2)
-> + DTD / Schema conversion (2)
-> + Stylus Studio FAQ's (2)
-> - With Cocoon's XSP tag (1)
-> - FAQ: How do I start a styleshe... (1)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Priti VermaSubject: Xquery ques. How to check for empty attributes
Author: Priti Verma
Date: 26 Apr 2004 02:23 PM
An XQuery ques:

I have a following XML doc

<Loan LoanId="123" InterestRate="5.9"/>
<Loan LoanId="" InterestRate="6.0"/>

I need an XQuery solution that creates Loan records without the
LoanId attribute, when LoanId attribute is blank.

<Loan Id="123" Int="5.9"/>
<Loan Int="6.0"/>

Posttop
Minollo I.Subject: Re: Xquery ques. How to check for empty attributes
Author: Minollo I.
Date: 26 Apr 2004 04:10 PM
One way to do that is:

<Loans>
{
for $Loan in /Loans/Loan
return
if($Loan/@LoanId and string-length($Loan/@LoanId)>0) then
<Loan Int="{$Loan/@InterestRate}" Id="{$Loan/@LoanId}"/>
else
<Loan Int="{$Loan/@InterestRate}"/>
}
</Loans>

...which will work fine in Stylus 173i and its mapper.

A much cleaner solution would probably be:

<Loans>
{
for $Loan in /Loans/Loan
return
<Loan Int="{$Loan/@InterestRate}">
{
if($Loan/@LoanId and string-length($Loan/@LoanId)>0) then
(attribute Id {$Loan/@LoanId})
else ()
}
</Loan>
}
</Loans>

...this will work fine in BL173i if you manually edit/run it, but it won't
work in XQuery mapper; we are working to address this issue.

Minollo

   
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.