如何使用XSLT从第5行excel xml工作簿中删除前导和尾随空格

时间:2015-11-03 13:23:15

标签: xml xslt xslt-2.0

如何删除第5行excel xml工作簿单元格值的前导和尾随空格?我尝试了以下但没有锻炼

XSLT:

<xsl:strip-space elements="/ss:Workbook/ss:Worksheet/ss:Table/ss:Row[position() = 5]/ss:Cell/ss:Data"/>

修改

XML

<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Author>Jefferson D</Author>
  <LastAuthor>Jefferson D</LastAuthor>
  <Created>2015-10-29T17:10:31Z</Created>
  <LastSaved>2015-10-29T17:15:02Z</LastSaved>
  <Company>*CL</Company>
  <Version>12.0</Version>
 </DocumentProperties>
 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <AllowPNG/>
 </OfficeDocumentSettings>
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  <WindowHeight>22060</WindowHeight>
  <WindowWidth>34400</WindowWidth>
  <WindowTopX>-20</WindowTopX>
  <WindowTopY>-20</WindowTopY>
  <Date1904/>
  <ProtectStructure>False</ProtectStructure>
  <ProtectWindows>False</ProtectWindows>
 </ExcelWorkbook>
 <Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Bottom"/>
   <Borders/>
   <Font ss:FontName="Verdana"/>
   <Interior/>
   <NumberFormat/>
   <Protection/>
  </Style>
  <Style ss:ID="s16">
   <Font ss:FontName="Verdana" ss:Bold="1"/>
  </Style>
 </Styles>
 <Worksheet ss:Name="Sheet1">
  <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="10" x:FullColumns="1"
   x:FullRows="1">
   <Column ss:AutoFitWidth="0" ss:Width="176.0"/>
   <Column ss:AutoFitWidth="0" ss:Width="141.0"/>
   <Column ss:AutoFitWidth="0" ss:Width="152.0"/>
   <Row>
    <Cell ss:Index="2" ss:StyleID="s16"><Data ss:Type="String">Ad Report</Data></Cell>
   </Row>
   <Row ss:Index="3">
    <Cell><Data ss:Type="String">IssueNo: 1</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">IssueName: XXX</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">Issue Date: YYY</Data></Cell>
   </Row>
   <Row ss:StyleID="s16">
    <Cell><Data ss:Type="String">  Ad Name  </Data></Cell>
    <Cell><Data ss:Type="String">  UID   </Data></Cell>
    <Cell><Data ss:Type="String"> Status </Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">WWW</Data></Cell>
    <Cell><Data ss:Type="String">0A1</Data></Cell>
    <Cell><Data ss:Type="String">active</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">XXX</Data></Cell>
    <Cell><Data ss:Type="String">1B2</Data></Cell>
    <Cell><Data ss:Type="String">active</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">YYY</Data></Cell>
    <Cell><Data ss:Type="String">2C3</Data></Cell>
    <Cell><Data ss:Type="String">inactive</Data></Cell>
   </Row>
  </Table>
  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
   <Print>
    <ValidPrinterInfo/>
    <PaperSizeIndex>10</PaperSizeIndex>
    <HorizontalResolution>-4</HorizontalResolution>
    <VerticalResolution>-4</VerticalResolution>
   </Print>
   <ShowPageLayoutZoom/>
   <PageLayoutZoom>100</PageLayoutZoom>
   <Selected/>
   <Panes>
    <Pane>
     <Number>3</Number>
     <ActiveRow>13</ActiveRow>
     <ActiveCol>2</ActiveCol>
    </Pane>
   </Panes>
   <ProtectObjects>False</ProtectObjects>
   <ProtectScenarios>False</ProtectScenarios>
  </WorksheetOptions>
 </Worksheet>
</Workbook>

广告名称,UID,状态中的空格必须删除

1 个答案:

答案 0 :(得分:1)

使用normalize-space()功能。