У меня есть многострочный текст в столбце SQL, и я получаю данные из запроса SQL.Мой запрос вставляется в конце каждой строки.
Запрос:
Declare @vcFooterText Varchar(max)
Select @vcFooterText = (Select replace(replace(AppConfigValue,CHAR(13),'
'),CHAR(10),'
') From COM.Config_Application With (NoLock) Where AppConfigId = 'PackingNoteFooterText')
Select @vcFooterText
Результат запроса:
Line 1
Line 2 
Line 3
Затем используется XML, который показывает данные:
Select tbl.OrderNumber, Cast(
(
'<Documents><Document><PackingNote>' +
Cast((
Select
CustomerName CustomerName,
Convert(Varchar(10), OrderCreatedOn, 103) + ' ' + Convert(Varchar(5), OrderCreatedOn, 114) As OrderDate,
CustomerNumber CustomerNumber,
OrderNumber OrderNumber,
BatchNumber BatchNumber,
ChannelOrderNumber ChannelOrderNumber,
OrderChannel OrderChannel,
Case
When DM.Category = 1501 ANd DM.SubCategory <> 1604 Then 'Click and Collect'
When DM.Category = 1502 Then 'Home Delivery'
End 'OrderType',
@vCompanyName as CompanyName,
@vCompanyEmail as CompanyEmail,
@vCompanyURL as CompanyURL,
@vCollectionPointValue as CollectionPointValue,
Case
when @vCheckCollectionPoint = 'True' Then 'Collection Point'
END 'CollectionPoint',
Case
When DM.Category = 1501 ANd DM.SubCategory <> 1604 Then 'Collect'
When DM.Category = 1502 Then 'Despatch'
When DM.Category = 1501 And DM.SubCategory = 1604 Then (Select AppConfigValue from Catalogue.COM.Config_Application
Where AppConfigId='SameDayShippingLabel')
End 'DeliveryMethod',
(Case When DM.Category = 1502 Then 1 Else 0 End) As 'IsHomeDelivery',
(CASE
WHEN DM.Category = 1502
THEN
CAST(
(
SELECT
ISNULL(OA.Name, CustomerName) CustomerName,
OA.AddressLines AddressLines,
OA.City City,
OA.PostalCode PostalCode,
OA.Country Country
FROM COM.Order_Address OA WITH (NoLock)
INNER JOIN COM.DeliveryMethod DM WITH (NoLock) ON DM.pkDeliveryMethodId = tbl.DeliveryMethodId
AND (DM.Category = 1502
OR DM.SubCategory = 1604) --HomeDelivery
AND OA.OrderId = tbl.OrderId
AND OA.AddressType = 'SHIP'
FOR
XML PATH('')
) AS XML
)
ELSE
CAST(
(
SELECT
ISNULL(B.Name, CustomerName) CustomerName,
A.Street AddressLines,
A.City City,
A.PostalCode PostalCode,
A.County Country
FROM Catalogue..Branch B WITH (NoLock)
INNER JOIN Catalogue.COM.[Order] O WITH (NoLock) ON O.CollectStoreId = B.pkBranchID
INNER JOIN Catalogue..[Address] A WITH (NoLock) ON A.fkBranchID = O.CollectStoreId
INNER JOIN COM.DeliveryMethod DM WITH (NoLock) ON DM.pkDeliveryMethodId = tbl.DeliveryMethodId
AND (DM.Category = 1501
OR DM.SubCategory <> 1604) --CC
AND O.pkOrderId = tbl.OrderId
FOR
XML PATH('')
) AS XML
)
END )
AS 'DeliveryAddress'
From COM.DeliveryMethod DM With (NoLock) Where DM.pkDeliveryMethodId = tbl.DeliveryMethodId
For Xml Path('Header'), Type
) As NVarchar(Max)) +
Cast((
Select SKU As 'Line/SKU',
Quantity As 'Line/Quantity',
ProductName As 'Line/ProductName',
Barcode As 'Line/Barcode',
Price As 'Line/Price'
From @tblPrintOrderLines Where OrderNumber = tbl.OrderNumber
For Xml Path('Lines'), Type
) As Varchar(Max)) +
Cast((
Select SUM(Quantity),
OrderNotes OrderNotes,
@vcFooterText As Text
From @tblPrintOrderLines Where OrderNumber = tbl.OrderNumber
For Xml Path('TotalItems'), Type
) As Varchar(Max)) +
'</PackingNote></Document></Documents>'
)
As XML) As 'XML',
@xmlTemplate As XSLT
From @tblOrderData tbl
Содержимое XML:
Это созданное содержимое XML:
<Documents>
<Document>
<PackingNote>
<Header>
<CustomerName>laura haines</CustomerName>
<OrderDate>15/09/2017 20:38</OrderDate>
<CustomerNumber>000003</CustomerNumber>
<OrderNumber>000024</OrderNumber>
<BatchNumber>1 of 1</BatchNumber>
<OrderType>Click and Collect</OrderType>
<CompanyName>The Retail Suite</CompanyName>
<CompanyURL />
<DeliveryMethod>Collect</DeliveryMethod>
<IsHomeDelivery>0</IsHomeDelivery>
<DeliveryAddress>
<CustomerName>ACC</CustomerName>
<AddressLines>London</AddressLines>
<City>London</City>
</DeliveryAddress>
</Header>
<Lines>
<Line>
<SKU>000044</SKU>
<Quantity>9</Quantity>
<ProductName>Partial Cancel 001</ProductName>
<Price>135.00</Price>
</Line>
</Lines>
<TotalItems>9<Text>Line 1&#xD;Line 2 &#xD;Line 3</Text></TotalItems>
</PackingNote>
</Document>
</Documents>
Как я могу получить разрывы строк, используя XSL 1.0?
XSLT 1.0:
<fo:table-row>
<fo:table-cell padding-bottom="1mm" padding-left="0.5cm">
<fo:block font-size="10pt" text-align="left">
<xsl:value-of select="text" />
</fo:block>
</fo:table-cell>
</fo:table-row>
Токовый выход:
Line 1
Line 2 
Line 3
Ожидаемый результат:
Line 1
Line 2
Line 3