0
<?xml version="1.0" encoding="utf-8"?>
<RS xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:saw-sql="urn:saw-sql" targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset">
    <xsd:complexType name="R">
        <xsd:sequence>
            <xsd:element name="C0" type="xsd:string" minOccurs="0" maxOccurs="1" saw-sql:type="varchar" saw-sql:displayFormula="&quot;Inventory Org&quot;.&quot;Inventory Org Name&quot;" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="Replenishments_Fact" saw-sql:columnHeading="Source Organization" saw-sql:columnID="c7"/>
            <xsd:element name="C1" type="xsd:string" minOccurs="0" maxOccurs="1" saw-sql:type="varchar" saw-sql:displayFormula="&quot;Item Inventory Product&quot;.&quot;Product Number&quot;" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="Item" saw-sql:columnHeading="Kanban Item" saw-sql:columnID="c1"/>
            <xsd:element name="C2" type="xsd:string" minOccurs="0" maxOccurs="1" saw-sql:type="varchar" saw-sql:displayFormula="&quot;Kanban Cards&quot;.&quot;Kanban Card Number&quot;" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="Kanban Card" saw-sql:columnHeading="Card Number" saw-sql:columnID="c0"/>
            <xsd:element name="C3" type="xsd:int" minOccurs="1" maxOccurs="1" saw-sql:type="integer" saw-sql:displayFormula="&quot;Fact - Kanban Card Activity&quot;.&quot;# of Replenishment Cycles&quot;" saw-sql:aggregationRule="sum" saw-sql:aggregationType="agg" saw-sql:tableHeading="Replenishments_Fact" saw-sql:columnHeading="Replenishment Cycle" saw-sql:columnID="c8"/>
            <xsd:element name="C4" type="xsd:string" minOccurs="0" maxOccurs="1" saw-sql:type="varchar" saw-sql:displayFormula="&quot;Storage Location&quot;.&quot;Subinventory Location&quot;" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="Replenishments_Fact" saw-sql:columnHeading="Subinventory" saw-sql:columnID="c2"/>
            <xsd:element name="C5" type="xsd:dateTime" minOccurs="0" maxOccurs="1" saw-sql:type="timestamp" saw-sql:displayFormula="&quot;Time&quot;.&quot;Date&quot;" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="Replenishments_Fact" saw-sql:columnHeading="Activity Date" saw-sql:columnID="c3"/>
            <xsd:element name="C6" type="xsd:string" minOccurs="0" maxOccurs="1" saw-sql:type="varchar" saw-sql:displayFormula="&quot;Kanban Codes&quot;.&quot;Kanban Card Status&quot;" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="Replenishments_Fact" saw-sql:columnHeading="Card Status" saw-sql:columnID="c4"/>
            <xsd:element name="C7" type="xsd:string" minOccurs="0" maxOccurs="1" saw-sql:type="varchar" saw-sql:displayFormula="&quot;Kanban Codes&quot;.&quot;Kanban Source Type&quot;" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="Replenishments_Fact" saw-sql:columnHeading="Supply Type" saw-sql:columnID="c5"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>
<R>
    <C0>Vision Operations</C0>
    <C1>f_item</C1>
    <C2>1</C2>
    <C3>4</C3>
    <C4>Stores</C4>
    <C5>2011-10-13T00:00:00</C5>
    <C6>Active</C6>
    <C7>Supplier</C7>
</R>
<R>
    <C0>SManufacturing</C0>
    <C1>KB18759</C1>
    <C2>100</C2>
    <C3>2</C3>
    <C4>Stores</C4>
    <C5>1999-02-03T00:00:00</C5>
    <C6>Active</C6>
    <C7>Supplier</C7>
</R>

我想要这样的结果,整数被转换为小数并且模式已被删除。解析应该是动态的,因为行是矿石。请帮我

<?xml version="1.0" encoding="UTF-8"?>
 <RS xmlns="urn:schemas-microsoft-com:xml-analysis:rowset"> 
<R>
<C0>Vision Operations</C0>
<C1>f_item</C1>
<C2>1.00000</C2>
<C3>4.00000</C3>
<C4>Stores</C4>
<C5>2011-10-13T00:00:00</C5>
<C6>Active</C6>
<C7>Supplier</C7>
</R>
<R>
<C0>Seattle Manufacturing</C0> 
<C1>KB18759</C1>
 <C2>100.00000</C2>
<C3>2.00000</C3>
<C4>Stores</C4>
<C5>1999-02-03T00:00:00</C5>
<C6>Active</C6>
<C7>Supplier</C7>
</R>
 </RS>

以上是所需的最终输出。解析所有值并将整数转换为小数

4

1 回答 1

1

你想要一个样式表:

默认情况下复制元素的标识模板

<xsl:template match="*">
  <xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>

删除架构元素的模板

<xsl:template match="*:schema"/>

将整数转换为十进制表示法的模板

<xsl:template match="*[not(*)][translate(., '0123456789', '') = '']">
  <xsl:copy>
    <xsl:value-of select="format-number(number(.), '0.00000')"/>
  </xsl:copy>
</xsl:template>

以上都是 XSLT 1.0。第三个模板可以用 XSLT 2.0 做得更好一些:

match="*[. castable as xs:integer]".

于 2013-08-14T16:57:01.097 回答