简体   繁体   中英

Upon doing a XSL Transform to XML how do I remove white space from a Node's attribute or data?

I have a part's list built out in XML and each part is labeled as such:

<division>
<parts>
    <part number="123456     " drawing="123456    " cad="y">
        <attribute>
            <header>Header</header>
            <list>2</list>
        </attribute>
    </part>

And I need to get the data behind the number and drawing attributes without the white space. I tried xsl:strip-space on the specific elements, and across the board, but that only strips the content in between the tags. I unfortunately have no access to the back-end that's producing the XML, so removing the spaces there doesn't look like an option.

You can use either:

normalize-space ()

or

translate (.,' &#9;&#xA;&#xC;', '')

The first will eliminate the leading and trailing whitespace in the string, and will also replace any other (inner) whitespace with a single space.

The second eliminates all whitespace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM