Removing blank lines in XSLT

2019-01-20 03:59发布

I'm using:

<xsl:template match="material_id | location_code"></xsl:template>

To get rid of elements in the source XML called material_id and location_code, but whitespace lines remain, leaving an output XML something like:

<entries>
    <Identity>conflab1</Identity>


    <price>24.36</price>
    <pricedate>15-Jul-2010 13:35:18 UTC</price_date>
</entries>

How should I stop it from leaving the newline characters?

Thanks,

Matt

2条回答
Summer. ? 凉城
2楼-- · 2019-01-20 04:50

You should combine strip-space and preserve-space together, so that you strip all spaces except those you define, eg:

<xsl:preserve-space  elements="Identity price price_date"/>
<xsl:strip-space  elements="*"/>

Source: https://www.w3schools.com/xml/ref_xsl_el_strip-space.asp

查看更多
对你真心纯属浪费
3楼-- · 2019-01-20 04:55

Try:

<xsl:strip-space  elements="*"/>

at the top of the document.

查看更多
登录 后发表回答