[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

How to add an optional attiribute to a constructed XML tag with XQuery ?

Diraviam H Diraviam.H at hcl.in
Tue Feb 17 11:44:57 PST 2009


  How to add an optional attiribute to a constructed
	XML tag with XQuery ?
I am creating an XML file say A, from another xml file B. The content of
file B will be changing and some tags can have optional attributes. I
want to include the attribute in the constructed XML file tag(s) through
Xquery, only when it is available in source file B.

I am trying something like this, where the attribute "name" is optional
in source.

 

let $x:= doc("source.xml")

for $comp in $x/Unit/Data/Organization

return

<Unit>

<Company type="{$comp/@type}" primary="{$org/@primary}"
{if(fn:exists($x/Unit/Data/Organization/@name)) then name="{$org/@name}"
else "" } >

</Detail></Detail>

</Company>

</Unit>



DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have 
received this email in error please delete it and notify the sender immediately. Before opening any mail and 
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20090217/742f674e/attachment.htm


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.