Mani Pazhana
asked on
XSLT - Text Warpping issue
Here is my issue:
Remark tag is having some issue by wrapping into two lines... (we are seeing CR LF in the output)
Here is the Input XMl:
<root xmlns="http://integration.cbre.com/schemas/gcs/batchinvoice/v2">
<Invoice xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1">
<ClientId>ATT</ClientId>
<OriginatingInvoiceId>1970 </Originat ingInvoice Id>
<VendorId>242354</VendorId >
<AlternativeVendorId>PRV-1 3-1307</Al ternativeV endorId>
<VendorInvoiceNumber>13-80 41</Vendor InvoiceNum ber>
<InvoiceDate>2013-08-08T00 :00:00</In voiceDate>
<InvoiceReceiveDate>2013-0 8-15T00:00 :00</Invoi ceReceiveD ate>
<GLDate>2013-08-21T20:53:0 3.81-05:00 </GLDate>
<Remark>Please repair torn and worn carpet squares on the sales floor.
972-409-0026</Remark>
<TotalInvoiceAmount>239.23 </TotalInv oiceAmount >
<CurrencyCode>USD</Currenc yCode>
<StatusCode>
<common:Code>Authorized</c ommon:Code >
<common:Description>Author ized</comm on:Descrip tion>
</StatusCode>
<ClientApprovalNumber>1000 119702</Cl ientApprov alNumber>
<InvoiceSource>COR</Invoic eSource>
<NumberOfLines>3</NumberOf Lines>
<InvoiceLineItems>
<InvoiceLineItem>
<OriginatingInvoiceLineID> 4637</Orig inatingInv oiceLineID >
<POLineNumber>34</POLineNu mber>
<LineItemDescription>Repla ce case of carpet tiles on sales floor. 1 tech 2 hrs 2013-08-08T00:00:00</LineI temDescrip tion>
<LocationId>ATR002037</Loc ationId>
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>76.000000< /LineItemA mount>
<GLAccount>
<CompanyId>51765</CompanyI d>
<GLAccountCode>51765</GLAc countCode>
<AccountBlock>51765</Accou ntBlock>
<GLAccountDescription>5176 5</GLAccou ntDescript ion>
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000 1</WorkOrd erNumber>
<WorkOrderCompletedDate>20 13-08-19T1 6:12:38</W orkOrderCo mpletedDat e>
<WorkOrderCreatedDate>2013 -08-01T12: 49:00</Wor kOrderCrea tedDate>
<CodingBlock1>Labor</Codin gBlock1>
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Replace case of carpet tiles on sales floor. 1 tech 2 hrs</CodingBlock4>
<CodingBlock5>Flooring</Co dingBlock5 >
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID> 4638</Orig inatingInv oiceLineID >
<POLineNumber>35</POLineNu mber>
<LineItemDescription>carpe t, glue</LineItemDescription>
<LocationId>ATR002037</Loc ationId>
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>145.000000 </LineItem Amount>
<GLAccount>
<CompanyId>51765</CompanyI d>
<GLAccountCode>51765</GLAc countCode>
<AccountBlock>51765</Accou ntBlock>
<GLAccountDescription>5176 5</GLAccou ntDescript ion>
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000 1</WorkOrd erNumber>
<WorkOrderCompletedDate>20 13-08-19T1 6:12:38</W orkOrderCo mpletedDat e>
<WorkOrderCreatedDate>2013 -08-01T12: 49:00</Wor kOrderCrea tedDate>
<CodingBlock1>Materials</C odingBlock 1>
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>carpet, glue</CodingBlock4>
<CodingBlock5>Flooring</Co dingBlock5 >
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID> 4636</Orig inatingInv oiceLineID >
<POLineNumber>36</POLineNu mber>
<LineItemDescription>Tax</ LineItemDe scription>
<LocationId>ATR002037</Loc ationId>
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>18.230000< /LineItemA mount>
<GLAccount>
<CompanyId>51765</CompanyI d>
<GLAccountCode>51765</GLAc countCode>
<AccountBlock>51765</Accou ntBlock>
<GLAccountDescription>5176 5</GLAccou ntDescript ion>
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000 1</WorkOrd erNumber>
<WorkOrderCompletedDate>20 13-08-19T1 6:12:38</W orkOrderCo mpletedDat e>
<WorkOrderCreatedDate>2013 -08-01T12: 49:00</Wor kOrderCrea tedDate>
<CodingBlock1>Tax</CodingB lock1>
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Tax</CodingB lock4>
<CodingBlock5>Flooring</Co dingBlock5 >
</AdditionalCoding>
</InvoiceLineItem>
</InvoiceLineItems>
</Invoice>
</root>
-------------------------- ---------- ---------- ------
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://integration.cbre.com/schemas/gcs/batchinvoice/v2">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="new-root-node">
<xsl:text>root</xsl:text>
</xsl:variable>
<!-- ITP is expecting multiple rows to be wrapped with batch -->
<xsl:template match="/*">
<!-- Create a new element with new node name. -->
<xsl:element name="{$new-root-node}">
<!-- Copy all children of the root node. -->
<xsl:copy-of select="*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
-------------------------- ----
can we fix the wrapping issue <Remark> </Remark> in the XSLT?
Thanks
Remark tag is having some issue by wrapping into two lines... (we are seeing CR LF in the output)
Here is the Input XMl:
<root xmlns="http://integration.cbre.com/schemas/gcs/batchinvoice/v2">
<Invoice xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1">
<ClientId>ATT</ClientId>
<OriginatingInvoiceId>1970
<VendorId>242354</VendorId
<AlternativeVendorId>PRV-1
<VendorInvoiceNumber>13-80
<InvoiceDate>2013-08-08T00
<InvoiceReceiveDate>2013-0
<GLDate>2013-08-21T20:53:0
<Remark>Please repair torn and worn carpet squares on the sales floor.
972-409-0026</Remark>
<TotalInvoiceAmount>239.23
<CurrencyCode>USD</Currenc
<StatusCode>
<common:Code>Authorized</c
<common:Description>Author
</StatusCode>
<ClientApprovalNumber>1000
<InvoiceSource>COR</Invoic
<NumberOfLines>3</NumberOf
<InvoiceLineItems>
<InvoiceLineItem>
<OriginatingInvoiceLineID>
<POLineNumber>34</POLineNu
<LineItemDescription>Repla
<LocationId>ATR002037</Loc
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>76.000000<
<GLAccount>
<CompanyId>51765</CompanyI
<GLAccountCode>51765</GLAc
<AccountBlock>51765</Accou
<GLAccountDescription>5176
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000
<WorkOrderCompletedDate>20
<WorkOrderCreatedDate>2013
<CodingBlock1>Labor</Codin
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Replace case of carpet tiles on sales floor. 1 tech 2 hrs</CodingBlock4>
<CodingBlock5>Flooring</Co
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID>
<POLineNumber>35</POLineNu
<LineItemDescription>carpe
<LocationId>ATR002037</Loc
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>145.000000
<GLAccount>
<CompanyId>51765</CompanyI
<GLAccountCode>51765</GLAc
<AccountBlock>51765</Accou
<GLAccountDescription>5176
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000
<WorkOrderCompletedDate>20
<WorkOrderCreatedDate>2013
<CodingBlock1>Materials</C
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>carpet, glue</CodingBlock4>
<CodingBlock5>Flooring</Co
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID>
<POLineNumber>36</POLineNu
<LineItemDescription>Tax</
<LocationId>ATR002037</Loc
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>18.230000<
<GLAccount>
<CompanyId>51765</CompanyI
<GLAccountCode>51765</GLAc
<AccountBlock>51765</Accou
<GLAccountDescription>5176
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000
<WorkOrderCompletedDate>20
<WorkOrderCreatedDate>2013
<CodingBlock1>Tax</CodingB
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Tax</CodingB
<CodingBlock5>Flooring</Co
</AdditionalCoding>
</InvoiceLineItem>
</InvoiceLineItems>
</Invoice>
</root>
--------------------------
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://integration.cbre.com/schemas/gcs/batchinvoice/v2">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="new-root-node">
<xsl:text>root</xsl:text>
</xsl:variable>
<!-- ITP is expecting multiple rows to be wrapped with batch -->
<xsl:template match="/*">
<!-- Create a new element with new node name. -->
<xsl:element name="{$new-root-node}">
<!-- Copy all children of the root node. -->
<xsl:copy-of select="*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
--------------------------
can we fix the wrapping issue <Remark> </Remark> in the XSLT?
Thanks
ASKER
Thanks.
i am only using <xsl:copy-of select="*" /> to copy all the child content.. i am not using <xsl:value-of select
any idea?
i am only using <xsl:copy-of select="*" /> to copy all the child content.. i am not using <xsl:value-of select
any idea?
Ah, I missed that, sorry
You need to make a deep copy not using copy-of but using apply-templates (a so called identity copy)
You can only control part of your deep copy, if you take control by having a template for each level in the tree
You need to make a deep copy not using copy-of but using apply-templates (a so called identity copy)
You can only control part of your deep copy, if you take control by having a template for each level in the tree
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://integration.cbre.com/schemas/gcs/batchinvoice/v2">
<xsl:output method="xml" indent="yes" />
<xsl:param name="new-root-node" select="'root'"/>
<!-- ITP is expecting multiple rows to be wrapped with batch -->
<xsl:template match="/*">
<!-- Create a new element with new node name. -->
<xsl:element name="{$new-root-node}">
<!-- Copy all children of the root node. -->
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Remark">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:value-of select="normalize-space(.)"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
ASKER
Thanks.
do we need to apply this template somewhere in the code...
<xsl:template match="Remark">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:value-of select="normalize-space(.) "/>
</xsl:copy>
</xsl:template>
do we need to apply this template somewhere in the code...
<xsl:template match="Remark">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:value-of select="normalize-space(.)
</xsl:copy>
</xsl:template>
We have it in every template
<xsl:apply-templates select="node()"/>
Except in the Remark template, because we have no further children there, we just want to show the textual content, with the newlines removed. That is what normalize-space() does
<xsl:apply-templates select="node()"/>
Except in the Remark template, because we have no further children there, we just want to show the textual content, with the newlines removed. That is what normalize-space() does
xsl:apply-templates essentialy says... "process the children"
ASKER
Got it.
i am still having issue.
Can you test this XML:
<root xmlns="http://integration.cbre.com/schemas/gcs/batchinvoice/v2">
<Invoice xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1">
<ClientId>ATT</ClientId>
<OriginatingInvoiceId>1970 </Originat ingInvoice Id>
<VendorId>242354</VendorId >
<AlternativeVendorId>PRV-1 3-1307</Al ternativeV endorId>
<VendorInvoiceNumber>13-80 41</Vendor InvoiceNum ber>
<InvoiceDate>2013-08-08T00 :00:00</In voiceDate>
<InvoiceReceiveDate>2013-0 8-15T00:00 :00</Invoi ceReceiveD ate>
<GLDate>2013-08-21T20:53:0 3.81-05:00 </GLDate>
<Remark>Please repair torn and worn carpet squares on the sales floor.
972-409-0026</Remark>
<TotalInvoiceAmount>239.23 </TotalInv oiceAmount >
<CurrencyCode>USD</Currenc yCode>
<StatusCode>
<common:Code>Authorized</c ommon:Code >
<common:Description>Author ized</comm on:Descrip tion>
</StatusCode>
<ClientApprovalNumber>1000 119702</Cl ientApprov alNumber>
<InvoiceSource>COR</Invoic eSource>
<NumberOfLines>3</NumberOf Lines>
<InvoiceLineItems>
<InvoiceLineItem>
<OriginatingInvoiceLineID> 4637</Orig inatingInv oiceLineID >
<POLineNumber>34</POLineNu mber>
<LineItemDescription>Repla ce case of carpet tiles on sales floor. 1 tech 2 hrs 2013-08-08T00:00:00</LineI temDescrip tion>
<LocationId>ATR002037</Loc ationId>
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>76.000000< /LineItemA mount>
<GLAccount>
<CompanyId>51765</CompanyI d>
<GLAccountCode>51765</GLAc countCode>
<AccountBlock>51765</Accou ntBlock>
<GLAccountDescription>5176 5</GLAccou ntDescript ion>
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000 1</WorkOrd erNumber>
<WorkOrderCompletedDate>20 13-08-19T1 6:12:38</W orkOrderCo mpletedDat e>
<WorkOrderCreatedDate>2013 -08-01T12: 49:00</Wor kOrderCrea tedDate>
<CodingBlock1>Labor</Codin gBlock1>
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Replace case of carpet tiles on sales floor. 1 tech 2 hrs</CodingBlock4>
<CodingBlock5>Flooring</Co dingBlock5 >
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID> 4638</Orig inatingInv oiceLineID >
<POLineNumber>35</POLineNu mber>
<LineItemDescription>carpe t, glue</LineItemDescription>
<LocationId>ATR002037</Loc ationId>
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>145.000000 </LineItem Amount>
<GLAccount>
<CompanyId>51765</CompanyI d>
<GLAccountCode>51765</GLAc countCode>
<AccountBlock>51765</Accou ntBlock>
<GLAccountDescription>5176 5</GLAccou ntDescript ion>
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000 1</WorkOrd erNumber>
<WorkOrderCompletedDate>20 13-08-19T1 6:12:38</W orkOrderCo mpletedDat e>
<WorkOrderCreatedDate>2013 -08-01T12: 49:00</Wor kOrderCrea tedDate>
<CodingBlock1>Materials</C odingBlock 1>
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>carpet, glue</CodingBlock4>
<CodingBlock5>Flooring</Co dingBlock5 >
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID> 4636</Orig inatingInv oiceLineID >
<POLineNumber>36</POLineNu mber>
<LineItemDescription>Tax</ LineItemDe scription>
<LocationId>ATR002037</Loc ationId>
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>18.230000< /LineItemA mount>
<GLAccount>
<CompanyId>51765</CompanyI d>
<GLAccountCode>51765</GLAc countCode>
<AccountBlock>51765</Accou ntBlock>
<GLAccountDescription>5176 5</GLAccou ntDescript ion>
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000 1</WorkOrd erNumber>
<WorkOrderCompletedDate>20 13-08-19T1 6:12:38</W orkOrderCo mpletedDat e>
<WorkOrderCreatedDate>2013 -08-01T12: 49:00</Wor kOrderCrea tedDate>
<CodingBlock1>Tax</CodingB lock1>
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Tax</CodingB lock4>
<CodingBlock5>Flooring</Co dingBlock5 >
</AdditionalCoding>
</InvoiceLineItem>
</InvoiceLineItems>
</Invoice>
</root>
-------------------------- -------
when i see the output in Notepad++, i am still seeing CR LF.....
In Notepad++ we need to set View --->Show symbols --> Show All Characters...
Capture.PNG
i am still having issue.
Can you test this XML:
<root xmlns="http://integration.cbre.com/schemas/gcs/batchinvoice/v2">
<Invoice xmlns:common="http://integration.cbre.com/schemas/gcs/common/v1">
<ClientId>ATT</ClientId>
<OriginatingInvoiceId>1970
<VendorId>242354</VendorId
<AlternativeVendorId>PRV-1
<VendorInvoiceNumber>13-80
<InvoiceDate>2013-08-08T00
<InvoiceReceiveDate>2013-0
<GLDate>2013-08-21T20:53:0
<Remark>Please repair torn and worn carpet squares on the sales floor.
972-409-0026</Remark>
<TotalInvoiceAmount>239.23
<CurrencyCode>USD</Currenc
<StatusCode>
<common:Code>Authorized</c
<common:Description>Author
</StatusCode>
<ClientApprovalNumber>1000
<InvoiceSource>COR</Invoic
<NumberOfLines>3</NumberOf
<InvoiceLineItems>
<InvoiceLineItem>
<OriginatingInvoiceLineID>
<POLineNumber>34</POLineNu
<LineItemDescription>Repla
<LocationId>ATR002037</Loc
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>76.000000<
<GLAccount>
<CompanyId>51765</CompanyI
<GLAccountCode>51765</GLAc
<AccountBlock>51765</Accou
<GLAccountDescription>5176
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000
<WorkOrderCompletedDate>20
<WorkOrderCreatedDate>2013
<CodingBlock1>Labor</Codin
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Replace case of carpet tiles on sales floor. 1 tech 2 hrs</CodingBlock4>
<CodingBlock5>Flooring</Co
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID>
<POLineNumber>35</POLineNu
<LineItemDescription>carpe
<LocationId>ATR002037</Loc
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>145.000000
<GLAccount>
<CompanyId>51765</CompanyI
<GLAccountCode>51765</GLAc
<AccountBlock>51765</Accou
<GLAccountDescription>5176
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000
<WorkOrderCompletedDate>20
<WorkOrderCreatedDate>2013
<CodingBlock1>Materials</C
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>carpet, glue</CodingBlock4>
<CodingBlock5>Flooring</Co
</AdditionalCoding>
</InvoiceLineItem>
<InvoiceLineItem>
<OriginatingInvoiceLineID>
<POLineNumber>36</POLineNu
<LineItemDescription>Tax</
<LocationId>ATR002037</Loc
<BuildingName>7800 N MACARTHUR BLVD SPACE#17</BuildingName>
<LineItemAmount>18.230000<
<GLAccount>
<CompanyId>51765</CompanyI
<GLAccountCode>51765</GLAc
<AccountBlock>51765</Accou
<GLAccountDescription>5176
</GLAccount>
<AdditionalCoding>
<ClientPONumber />
<WorkOrderNumber>203700000
<WorkOrderCompletedDate>20
<WorkOrderCreatedDate>2013
<CodingBlock1>Tax</CodingB
<CodingBlock2>Carpet Replace</CodingBlock2>
<CodingBlock4>Tax</CodingB
<CodingBlock5>Flooring</Co
</AdditionalCoding>
</InvoiceLineItem>
</InvoiceLineItems>
</Invoice>
</root>
--------------------------
when i see the output in Notepad++, i am still seeing CR LF.....
In Notepad++ we need to set View --->Show symbols --> Show All Characters...
Capture.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect. It worked. Thanks.
welcome
ASKER
answered
Do you want the CRLF to be removed?
then simply do a
<xsl:value-of select="normalize-space(.)
in the template for Remark