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
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Rajat NairSubject: Parent tags
Author: Rajat Nair
Date: 03 Mar 2009 04:37 PM
Originally Posted: 03 Mar 2009 04:09 PM
Hi,
Our Company is a Licensed enterprise edition user for Stylus studio.I have been running into the following issue.

code snippet:

{ if (/*:AcknowledgePurchaseOrder/*:DataArea/*:PurchaseOrder/*:PurchaseOrderHeader/*:SupplierParty/*:Contact/*:JobTitle/text() != null and /*:AcknowledgePurchaseOrder/*:DataArea/*:PurchaseOrder/*:PurchaseOrderHeader/*:SupplierParty/*:Contact/*:Communication/*:AreaDialing/text() != null )then
<ListOfReferenceCoded>
{
for $Contact /*:AcknowledgePurchaseOrder/*:DataArea/*:PurchaseOrder/*:PurchaseOrderHeader/*:SupplierParty/*:Contact
return

<ReferenceCoded>
<ReferenceTypeCoded>{$Contact/*:JobTitle/text()}</ReferenceTypeCoded>
<PrimaryReference>
<Reference>
<RefNum>{$Contact/*:Communication/*:AreaDialing/text()}</RefNum>
</Reference>
</PrimaryReference>
</ReferenceCoded>
}
</ListOfReferenceCoded>
else()
}

in the above code when the tags <ReferenceTypeCoded> and <RefNum> are empty i get <ListOfReferenceCoded\> in the final output, i tried to get rid of this by adding the if statement before the start of the <ListOfReferenceCoded> tag to ensure that this empty tag does not come in the final output, but instead the tag gets removed for both cases (when there is content and also when there is no content).Any help regarding this is greatly appreciated.

Regards
Rajat

Postnext
Minollo I.Subject: Parent tags
Author: Minollo I.
Date: 03 Mar 2009 04:24 PM
Consider that if you test something like if(/a/b != null), "null" is an XPath expression computed in the current context item, not "null" the way you would think about it in Java terms; typically you would say if (/a/b) then...

Anyway, have you tried adding an if condition like:
if($Contact /*:AcknowledgePurchaseOrder/*:DataArea/*:PurchaseOrder/*:PurchaseOrderHeader/*:SupplierParty/*:Contact) then ... else ()

If that doesn't help, we would need to take a look at the whole XQuery and a sample XML input.

Postnext
Rajat NairSubject: Parent tags
Author: Rajat Nair
Date: 03 Mar 2009 04:40 PM
Thx that worked !!

Postnext
Rajat NairSubject: Parent tags
Author: Rajat Nair
Date: 05 Mar 2009 11:30 AM
Hi,
I m working on xml-xml translators, for example

incoming xml:

<ShipToParty>
<PartyIDs>
<ID />
<TaxID />
<DUNSID />
<CAGEID>1234</CAGEID>
<DODAACID />
</PartyIDs>
</ShipToParty>

Ideal Outgoing xml:
<OrderResponseSummary>
<OriginalOrderSummary>
<OrderSummary>
<TotalAmount>
<MonetaryValue>
<MonetaryAmount>1234</MonetaryAmount>
</MonetaryValue>
</TotalAmount>
</OrderSummary>
</OriginalOrderSummary>
</OrderResponseSummary>

I assume the above mentioned solution would check if the tag exists in the incoming xml

"Consider that if you test something like if(/a/b != null), "null" is an XPath expression computed in the current context item, not "null" the way you would think about it in Java terms; typically you would say if (/a/b) then... "

but in this case the tags do exist however they are empty, is there a way where i could use the if condition and not show empty tags on the outgoing doc??.I would be grateful if you could point me in the right direction.

Regards
Rajat





DocumentOrderResponse.xquery
xquery file

Posttop
Minollo I.Subject: Parent tags
Author: Minollo I.
Date: 05 Mar 2009 11:54 AM
>...
>but in this case the tags do exist however they are empty, is there a
>way where i could use the if condition and not show empty tags on the
>outgoing doc??.I would be grateful if you could point me in the right
>direction.

if(/a/b/text()) then ... else ()

 
Go to previous topicPrev TopicGo to next topicNext Topic
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.