Hallo Leute ,
Breuchte euer hilfe,
ich muss mit SQL server XML Export (für schnittstelle) schreiben.
Ich habe folgende problem.
Fehler:
Die attributzentrierte 'custom-attributes/custom-attribute/@name'-Spalte darf in der XML-Hierarchie in FOR XML PATH nicht auf ein nicht attributzentriertes gleichgeordnetes Element folgen.
MEIN SQL
WITH XMLNAMESPACES(
'http://www.xxxxx.com/xml/ns/xyz' as x ,
'http://www.w3.org/2001/XMLSchema-instance' as xsi,
'http://www.xxxxx.com/xml/ns/xxx-dt' as dt
)
select top 2
USER_MinREF "@SKU",
USER_MinREF as SKU,
(case when wawiaktiv='-1' then 1 else 0 end) as "available",
(case when wawiaktiv='-1' then 1 else 0 end) as "available-status",
(case when ShopRPAktiv='-1' then 1 else 0 end) as "online",
'de-CH' as "name/@xml:lang",
Bezeichnung1 as "name",
'de-CH' as "Short-description/@xml:lang",
OlBezeichnung5 as "Short-description",
/* CUSTOM ATTRIBUTES*/
-- ** displayName ** --
'USER_Modell_displayName' as "custom-attributes/custom-attribute/@name",
'string' as "custom-attributes/custom-attribute/@dt:dt",
'de-CH' as "custom-attributes/custom-attribute/@xml:lang",
'Gender' as "custom-attributes/custom-attribute",
-- ** displayValue ** --
'USER_Modell_value' as "custom-attributes/custom-attribute/@name",
'string' as "custom-attributes/custom-attribute/@dt:dt",
USER_Modell as "custom-attributes/custom-attribute/USER_Modell_value"
from
artikel
FOR XML PATH ('product'), ROOT('myRoot')
MUSTER:
<myRootxmlns:dt="http://www.***.com/xml/ns/***/impex-dt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:x="http://www.***.com/xml/ns/***mpex">
<product SKU="52267215">
<SKU>52267215</SKU>
<available>1</available>
<available-status>1</available-status>
<online>0</online>
<name xml:lang="de-CH">PRODUKT1</name>
<Short-description xml:lang="de-CH">Produkt 1 beschreibung</Short-description>
<custom-attributes>
<custom-attribute name="USER_Modell_displayName" dt:dt="string" xml:lang="de-CH">Gender</custom-attribute>
<custom-attribute name="USER_Modell_value" dt:dt="string">Unisex</custom-attribute>
</custom-attributes>
</product>
<product SKU="52267215">
<SKU>52267215</SKU>
<available>1</available>
<available-status>1</available-status>
<online>0</online>
<name xml:lang="de-CH">Produkt2</name>
<Short-description xml:lang="de-CH">Produkt2 Beschreibung</Short-description>
<custom-attributes>
<custom-attribute name="USER_Modell_displayName" dt:dt="string" xml:lang="de-CH">Gender</custom-attribute>
<custom-attribute name="USER_Modell_value" dt:dt="string">Unisex</custom-attribute>
</custom-attributes>
</product>
</myRoot>
1.Wie kann ich das umsätzten
2. Gibt es andere weg =?
3. wie erstellt ihr aus MSSQL datenbank XML
Würde mich über jedes Positives antwort freuen.
Grüsse ASLAN4U