|
[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.inTue Feb 17 11:44:57 PST 2009
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






