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
最满意答案
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
相关问答
更多-
Docker,如何从容器内获取容器信息?(Docker, how to get container information from within the container?)[2022-06-21]
我发现容器ID可以在/ proc / self / cgroup中找到 所以你可以得到id: cat /proc/self/cgroup | grep -o -e "docker-.*.scope" | head -n 1 | sed "s/docker-\(.*\).scope/\\1/" I've found out that the container id can be found in /proc/self/cgroup So you can get the id with : cat /pr ... -
网络仅为容器共享。 虽然跨多个主机覆盖的容器之间共享网络,但是docker守护程序不能按原样在它们之间进行通信。 user@_node2_$ docker exec -i -t container1 bash不起作用,因为实际上no such id: container1从node2运行。 访问远程Docker守护程序 Docker守护进程通过套接字进行通信。 UNIX套接字默认情况下,但可以添加一个选项--host来指定守护程序应绑定到的其他套接字。 请参阅docker daemon手册页: -H, ...
-
使用docker commit时如何避免输入容器ID?(How to avoid typing the container id when using docker commit?)[2022-06-21]
我找到了答案,并认为我会发布它以防其他人遇到同样的问题: $ sudo docker commit -m "commit message" -a "author" \ $(sudo docker ps -lq) user/imagename:tag 你使用docker ps -lq I found the answer and thought I'd post it in case someone else runs into the same issue: $ sudo docker commit ... -
我决定离开詹金斯码头管道,改用原生码头突击队。 以下命令执行这个技巧。 注意:在任何情况下都不要使用git config部分! docker run --rm --privileged --name docker-builder \ -v /var/run/docker.sock:/var/run/docker.sock docker:dind \ /bin/sh -c 'apk add --no-cache git && \ git config --global http.sslVerify false ...
-
docker exec将只能运行在一个正在运行的容器上, ctrl - c通常会停止/终止一个容器。 一个容器可以运行分离 ,然后该命令将新的容器ID打印到标准输出。 cid=$(docker run --detach
) docker exec -ti $cid bash 如果您仍想查看容器输出,请使用docker logs $cid When the container is terminated, just do this to get the container id: $ dock ... -
您可以在Docker Compose文件中指定docker-compose.yaml docker-compose正在例如docker-compose.yaml上执行。 构建和部署以相同的方式工作。 只需将图像名称和标记设置为构建的子集,或指定单独的dockerfile。 version: '2' services: webapp: build: context: ./dir image: username/repository:tag 鉴于运行docker-compose ...
-
Docker:如何获取现有容器的完整容器ID?(Docker: How can I get the complete container id of a existing container?)[2023-05-20]
让我们说从这张图片中,我想要完整的container_id:8a7815ffd059 docker inspect 8a78 | grep Id Lets say that from this picture, I want the full container_id of: 8a7815ffd059 docker inspect 8a78 | grep Id -
我想通了......那个容器bef8正在使用--net = host flag I figured it out... That container bef8 is using --net=host flag
-
您可以以分离模式启动容器: docker run -it -d my_container 这里的-d选项意味着您的容器将在后台以“分离”模式运行。 如果要附加容器并放入shell,可以使用: docker exec -it my_container /bin/bash You can start your container in a detached mode: docker run -it -d my_container The -d option here means your containe ...
-
您需要挖掘其他图像的docker history输出,以查看链接的内容。 有一个图像可以自动执行大部分操作,您可以使用以下命令运行: docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock \ nate/dockviz images -t -l 关于上述命令的更多细节可以在这个github repo上找到。 You need to dig through the docker history output for other ...