Hi
I have this weird issue with my xquery script.
The below script returns XML where the namespace prefixes are changed to weird generated namespace prefixes.
The result is valid, but is looking weird.
The namespace changes are located within the output for all elements included in the for loop, resulting in elements looking like this:
<ddtek-me1:DespatchLine xmlns:ddtek-me1="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
<ddtek-me2:DeliveredQuantity xmlns:ddtek-me2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" unitCode="STK">1</ddtek-me2:DeliveredQuantity>
This is the script:
declare namespace b = "urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2";
declare namespace a = "http://generic.xml.eetgroup.com";
declare namespace cbc = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2";
declare namespace cac = "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2";
declare option ddtek:serialize 'indent=yes,omit-xml-declaration=no';
for $Dispatch in /a:DispatchAdvice/a:Dispatch
return
<b:DespatchAdvice xmlns:b="urn:oasis:names:specification:ubl:schema:xsd:DespatchAdvice-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
<cbc:UBLVersionID>2.1</cbc:UBLVersionID>
<cbc:CustomizationID>somthing</cbc:CustomizationID>
<cbc:ProfileID>gggggg</cbc:ProfileID>
<cbc:ID>TODO: dispatch ID missing from Generic file</cbc:ID>
<cbc:IssueDate>{ year-from-date(current-date())}-{ month-from-date(current-date())}-{ day-from-date(current-date()) }</cbc:IssueDate>
{
for $DispatchLine in $Dispatch/a:DispatchLines/a:DispatchLine
return
<cac:DespatchLine>
<cbc:DeliveredQuantity unitCode="{ $DispatchLine/a:UnitOfMeasure/text() }">
{ $DispatchLine/a:DeliveredQuantity/text() }
</cbc:DeliveredQuantity>
<cac:bcOrderLineReference>
<cbc:LineID>
{$DispatchLine/a:OrderLineReference/text() }
</cbc:LineID>
</cac:bcOrderLineReference>
<cac:Item>
<cbc:Description>
{ $DispatchLine/a:Item/a:Description/text() }
</cbc:Description>
<cac:SellersItemIdentification>
{ $DispatchLine/a:Item/a:VendorsItemNo/text() }
</cac:SellersItemIdentification>
<cac:ManufacturersItemIdentification>
<cbcID>
{ $DispatchLine/a:Item/a:ManufacturerPartNo/text() }
</cbcID>
</cac:ManufacturersItemIdentification>
<cac:StandardItemIdentification>
<cbc:ID>
{ $DispatchLine/a:Item/a:EAN/text() }
</cbc:ID>
</cac:StandardItemIdentification>
</cac:Item>
</cac:DespatchLine>
}
</b:DespatchAdvice>
Appreciating any input, thanks.
sample_shipment.xml Conversion input
|