I have the following problem, I need to remove the \"cfdi_\" for \"cfdi:\"
I used the namespaces to solve that but they are duplicated by each node and I can not elimina
From XML prospective second result is self-sufficient XML element, while first result can be only part of other element where namespace for cfdi
prefix is defined.
So, I guess all works as you defined.
Sub-select
(SELECT Importe, TasaCuota, TipoFactor, Impuesto, Base
FROM CDFIDet
FOR XML RAW('cfdi:traslado'), TYPE, ROOT('cfdi:traslados'))
produces self-sufficient result as
because you defined ROOT('cfdi:traslados')
- you have namespace in it, and nested elements cfdi:traslado
are in the same namespace - there is no separate namespace declaration.
Then top select:
SELECT
'' AS importe,
(SELECT Importe, TasaCuota, TipoFactor, Impuesto, Base
FROM CDFIDet
FOR XML RAW('cfdi:traslado'), TYPE, ROOT('cfdi:traslados'))
FROM CFDIENC
FOR XML RAW('cfdi:gatito'), TYPE)
defines a root element for cfdi:traslados
as cfdi:gatito
it has its own namespace declaration for cfdi
prefix.
I'm not familiar with sql-server XML, but what will happen if you remove
ROOT('cfdi:traslados')
from sub-select?
Will it remove xmlns:cfdi="uri"
from
element?