首页 \ 问答 \ Sql Server 2008R2 XML导出(Sql Server 2008R2 XML export)

Sql Server 2008R2 XML导出(Sql Server 2008R2 XML export)

将数据从数据库导出到XML时遇到一些问题。 我可能已经过头了,因为我没有早期的XML知识但嘿,它有多难啊:)

我们已经通过excel表发送了这些数据,但现在客户想要它作为XML。 上传到他们的系统后,我可以将其下载为XML,而下面是该文件的一部分,

    <?xml version="1.0" encoding="ISO-8859-1"?>
<PricatHead xmlns="xxxxx"
           preOrderTo="2015-06-01T23:59:59"
           name="15005-3"
           merchant="xxxx"
           customer="xxxxx"
           validFrom="2014-08-01T00:00:00"
           validTo="2015-06-01T23:59:59"
           currency="SEK"
           contractDiscount="0">
  <sprProduct itemID="86035-8"
              name="xxxx"
              description="xxxxxx"
              tax="0.00"
              eanCode=""
              eanType="EAN 13"
              color="BLACK"
              colorCode="C0100"
              size="36"
              sizeRange="EURO size"
              modelNo="86035"
              inSelection="N"
              productDiscount="0">
    <priceBracket quantity="1"
                  price="x"
                  grossPrice="xxxx"
                  validOrderDateFrom="2014-08-01T00:00:00"
                  validOrderDateTo="2015-06-01T00:00:00"
                  validShipDateFrom="2015-02-15T00:00:00"
                  validShipDateTo="2015-06-01T00:00:00"
                  type="PRE"/>
    <priceBracket quantity="1"
                  price="x"
                  grossPrice="x"
                  validOrderDateFrom="2015-02-15T00:00:00"
                  validOrderDateTo="2015-06-01T00:00:00"
                  validShipDateFrom="2015-02-15T00:00:00"
                  validShipDateTo="2015-06-01T00:00:00"
                  type=""/>
    <variantValue name="unit"
                  value="pcs"/>
    <variantValue name="recPrice_SEK"
                  value="x"/>
    <variantValue name="recCampaignPrice_SEK"
                  value="0"/>
    <variantValue name="brand"
                  value="x"/>
    <variantValue name="goodsClass"
                  value="4052"/>
    <variantValue name="recCampaignPriceCurrency"
                  value="SEK"/>
    <variantValue name="recWebPriceCurrency"
                  value="SEK"/>
    <variantValue name="unitType"
                  value="pcs"/>
    <variantValue name="x"
                  value="2603"/>
    <variantValue name="marketingInfo"
                  value="xxxxx"/>
    <variantValue name="preOrderDiscountHQ"
                  value="0"/>
    <variantValue name="grossPriceCurrency"
                  value="SEK"/>
    <variantValue name="productPicture_1"
                  value="xxx"/>
    <variantValue name="suppOrderCurrency"
                  value="SEK"/>
    <variantValue name="preOrderCurrency"
                  value="SEK"/>
    <variantValue name="productPicture_3"
                  value="xxx"/>
    <variantValue name="productPicture_2"
                  value="xxxx"/>
    <variantValue name="invoiceMethod"
                  value="net"/>
    <variantValue name="logisticUnit"
                  value="cu"/>
    <variantValue name="countryOfOrigin"
                  value="CN"/>
    <variantValue name="suppOrderDiscountHQ"
                  value="0"/>
    <variantValue name="customsTariffNo_SE"
                  value="6402999300"/>
  </sprProduct>

对于excel表,我有一个SQL序列,它产生一个包含所有上述数据的大表,其中<sprProduct>是一行,其余列。 我没有问题创建<pricatHead><sprProduct>标签,但我失败了<priceBracket>因为它们也是select语句中的列,我有多个需要自己的<priceBracket><variantValue>会导致同样的问题。

难以解释但是一个sql行应该产生多个<priceBracket><variantValue>

到目前为止,我的代码如下(缩短),

--Pricat HEAD
select 
PrisLista as [@name]
,gtinMerchant as [@merchant]
,gtinCustomer as [@customer]

--Pricat ROWS
,(  select 
    ar.ArtNr as [@itemID]
    ,ar.ArtBeskr as [@name]
    ,ar.ArtBeskrLong as [@description]
    ,prl.vat as [@tax]
    ,prl.quantity as [sprProduct/priceBracket/@quantity] 
    .........
    from prl
    for xml path ('sprProduct'), type)


from prh 
FOR XML PATH ('PricatHead')

如何获取特定行的每列以生成具有属性值的自己的标记?

作为第二个问题,我还从客户那里获得了这个XML文件的XSD架构。 这可以用来帮助格式化从我的数据库导出的数据以匹配他们所需的XML文件吗?


I have some trouble exporting data from our database to XML. I'm probably in over my head as i have no earlier XML knowledge but hey, how hard can it be :)

We already send this data through an excel sheet but now the customer wants it as XML instead. After upload to their system i can download it as an XML instead and below is a part of that file,

    <?xml version="1.0" encoding="ISO-8859-1"?>
<PricatHead xmlns="xxxxx"
           preOrderTo="2015-06-01T23:59:59"
           name="15005-3"
           merchant="xxxx"
           customer="xxxxx"
           validFrom="2014-08-01T00:00:00"
           validTo="2015-06-01T23:59:59"
           currency="SEK"
           contractDiscount="0">
  <sprProduct itemID="86035-8"
              name="xxxx"
              description="xxxxxx"
              tax="0.00"
              eanCode=""
              eanType="EAN 13"
              color="BLACK"
              colorCode="C0100"
              size="36"
              sizeRange="EURO size"
              modelNo="86035"
              inSelection="N"
              productDiscount="0">
    <priceBracket quantity="1"
                  price="x"
                  grossPrice="xxxx"
                  validOrderDateFrom="2014-08-01T00:00:00"
                  validOrderDateTo="2015-06-01T00:00:00"
                  validShipDateFrom="2015-02-15T00:00:00"
                  validShipDateTo="2015-06-01T00:00:00"
                  type="PRE"/>
    <priceBracket quantity="1"
                  price="x"
                  grossPrice="x"
                  validOrderDateFrom="2015-02-15T00:00:00"
                  validOrderDateTo="2015-06-01T00:00:00"
                  validShipDateFrom="2015-02-15T00:00:00"
                  validShipDateTo="2015-06-01T00:00:00"
                  type=""/>
    <variantValue name="unit"
                  value="pcs"/>
    <variantValue name="recPrice_SEK"
                  value="x"/>
    <variantValue name="recCampaignPrice_SEK"
                  value="0"/>
    <variantValue name="brand"
                  value="x"/>
    <variantValue name="goodsClass"
                  value="4052"/>
    <variantValue name="recCampaignPriceCurrency"
                  value="SEK"/>
    <variantValue name="recWebPriceCurrency"
                  value="SEK"/>
    <variantValue name="unitType"
                  value="pcs"/>
    <variantValue name="x"
                  value="2603"/>
    <variantValue name="marketingInfo"
                  value="xxxxx"/>
    <variantValue name="preOrderDiscountHQ"
                  value="0"/>
    <variantValue name="grossPriceCurrency"
                  value="SEK"/>
    <variantValue name="productPicture_1"
                  value="xxx"/>
    <variantValue name="suppOrderCurrency"
                  value="SEK"/>
    <variantValue name="preOrderCurrency"
                  value="SEK"/>
    <variantValue name="productPicture_3"
                  value="xxx"/>
    <variantValue name="productPicture_2"
                  value="xxxx"/>
    <variantValue name="invoiceMethod"
                  value="net"/>
    <variantValue name="logisticUnit"
                  value="cu"/>
    <variantValue name="countryOfOrigin"
                  value="CN"/>
    <variantValue name="suppOrderDiscountHQ"
                  value="0"/>
    <variantValue name="customsTariffNo_SE"
                  value="6402999300"/>
  </sprProduct>

For the excel sheet i have an SQL proceedure that produces one big table with all the above data where <sprProduct> is one row and the rest columns. I have no problem to create the <pricatHead> and the <sprProduct> tags but i fail with the <priceBracket> as they are also columns in the select statement and i have multiple columns that need their own <priceBracket>. <variantValue> causes the same problem.

Difficult to explain but one sql row should produce multiple <priceBracket> and <variantValue>.

So far my code looks as below (shortened),

--Pricat HEAD
select 
PrisLista as [@name]
,gtinMerchant as [@merchant]
,gtinCustomer as [@customer]

--Pricat ROWS
,(  select 
    ar.ArtNr as [@itemID]
    ,ar.ArtBeskr as [@name]
    ,ar.ArtBeskrLong as [@description]
    ,prl.vat as [@tax]
    ,prl.quantity as [sprProduct/priceBracket/@quantity] 
    .........
    from prl
    for xml path ('sprProduct'), type)


from prh 
FOR XML PATH ('PricatHead')

How do i get each column for a specific row to produce its own tag with attributed values?

As a second question i also got an XSD schema for this XML file from the customer. Can this be used to help format the data exported from my database to match their required XML file?


原文:https://stackoverflow.com/questions/29274463
更新时间:2022-04-18 18:04

最满意答案

docker exec将只能运行在一个正在运行的容器上, ctrl - c通常会停止/终止一个容器。

一个容器可以运行分离 ,然后该命令将新的容器ID打印到标准输出。

cid=$(docker run --detach <image>)
docker exec -ti $cid bash

如果您仍想查看容器输出,请使用docker logs $cid


When the container is terminated, just do this to get the container id:

$ docker ps -a

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。