如何使XSL不将我的xsl:element和xsl:属性名称转换为小写?

时间:2015-08-15 00:20:59

标签: xml xslt

Hello StackOverFlow社区,

我创建了一个简单的XSL来将XML文件转换为另一个。

输出XML文件需要遵循我从供应商处收到的模式,该模式描述了遵循camelCase标准的元素。

例如,我需要创建元素:

<bfr5:remision>
  <brf5:infoBasica folio="19190" refID="19190" rfcReceptor="TTTTT" rfcEmisor="SSSSS5">
    <infoEspecial valor="19190"></infoEspecial>
  </brf5:infoBasica>
</bfr5:remision>

但是,当我运行我的XSL时,它会将元素和属性名称全部更改为小写。

<bfr5:remision>
  <brf5:infobasica folio="19190" refid="19190" rfcreceptor="TTTTT" rfcemisor="SSSSS5">
    <infoespecial valor="19190"></infoespecial>
  </brf5:infobasica>
</bfr5:remision>

这是整个XSL文件:

<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                              xmlns:bfr5="http://www.buzonfiscal.com/ns/xsd/bf/remision/52">
<xsl:output omit-xml-declaration="yes" indent="yes"/>

<xsl:template match="/">

  <xsl:element name="bfr5:Remision">

  <xsl:attribute name="version">5.2</xsl:attribute>

  <!-- Required for InfoBasica -->
  <xsl:variable name="custRegNo"    select="/Document/Letter/Customer/custRegNo"/>
  <xsl:variable name="invoiceNo"    select="/Document/Letter/InvoiceDetails/InvoiceHeader/invoiceNo"/>
  <xsl:variable name="folioNo"      select="/Document/Letter/InvoiceDetails/InvoiceHeader/folioAssign"/>
  <xsl:variable name="asignaFolio">false</xsl:variable>
  <xsl:variable name="lessorTaxId"  select="/Document/Letter/LetterDetails/Lessor/lessorTaxId"/>

  <!-- Required for InfoAdicional -->
  <xsl:variable name="paymentType"        select="/Document/Letter/InvoiceDetails/InvoiceHeader/paymentType"/>
  <xsl:variable name="subTotal"           select="/Document/Letter/InvoiceDetails/InvoiceHeader/totalDueWithLateCharge"/>
  <xsl:variable name="total"              select="/Document/Letter/InvoiceDetails/InvoiceHeader/totalDueWithLateCharge"/>
  <xsl:variable name="paymentMethod"       select="/Document/Letter/InvoiceDetails/InvoiceHeader/paymentMethod"/>
  <xsl:variable name="invoiceType"  select="/Document/Letter/InvoiceDetails/InvoiceHeader/invoiceType"/>
  <xsl:variable name="expeditionPlace"    select="/Document/Letter/InvoiceDetails/InvoiceHeader/expeditionPlace"/>

  <!-- Required for Emisor -->
  <xsl:variable name="regimen"  select="'Régimen General De Ley Personas Morales'"/>

  <!-- Required for DomicilioFiscal -->
  <xsl:variable name="addressStreet"    select="/Document/Letter/LetterDetails/Lessor/LessorAddress/addressStreetNameAndNumber"/>
  <xsl:variable name="addressCity"      select="/Document/Letter/LetterDetails/Lessor/LessorAddress/addressCity"/>
  <xsl:variable name="addressState"     select="/Document/Letter/LetterDetails/Lessor/LessorAddress/addressState"/>
  <xsl:variable name="addressCountry"   select="/Document/Letter/LetterDetails/Lessor/LessorAddress/addressCountry"/>
  <xsl:variable name="addressZip"       select="/Document/Letter/LetterDetails/Lessor/LessorAddress/addressPostalCode"/>

  <xsl:element name="bfr5:InfoBasica">

    <xsl:attribute name="rfcEmisor"><xsl:value-of select="$lessorTaxId"/></xsl:attribute>        
    <xsl:attribute name="rfcReceptor"><xsl:value-of select="$custRegNo"/></xsl:attribute>        
    <xsl:attribute name="refID"><xsl:value-of select="$invoiceNo"/></xsl:attribute>        
    <xsl:attribute name="folio"><xsl:value-of select="$folioNo"/></xsl:attribute>        
    <xsl:attribute name="asignaFolio"><xsl:value-of select="$asignaFolio"/></xsl:attribute>

    <xsl:element name="InfoEspecial">
      <xsl:attribute name="atributo">Invoice Number</xsl:attribute>          
      <xsl:attribute name="valor"><xsl:value-of select="$invoiceNo"/></xsl:attribute>        
    </xsl:element>      
  </xsl:element>

  <xsl:element name ="bfr5:InfoAdicional">

    <xsl:attribute name="formaDePago"><xsl:value-of select="$paymentType"/></xsl:attribute>
    <xsl:attribute name="subTotal"><xsl:value-of select="$subTotal"/></xsl:attribute>
    <xsl:attribute name="total"><xsl:value-of select="$total"/></xsl:attribute>
    <xsl:attribute name="metodoDePago"><xsl:value-of select="$paymentMethod"/></xsl:attribute>
    <xsl:attribute name="tipoDeComprobante"><xsl:value-of select="$invoiceType"/></xsl:attribute>
    <xsl:attribute name="lugarExpedicion"><xsl:value-of select="$expeditionPlace"/></xsl:attribute>

  </xsl:element>

  <xsl:element name ="bfr5:Emisor">        
    <xsl:element name="bfr5:RegimenFiscal">          
      <xsl:attribute name="Regimen"><xsl:value-of select="$regimen"/></xsl:attribute>              
    </xsl:element>      
  </xsl:element>

  <xsl:element name ="bfr5:DomicilioFiscal">

    <xsl:attribute name="calle"><xsl:value-of select="$addressStreet"/></xsl:attribute>
    <xsl:attribute name="municipio"><xsl:value-of select="$addressCity"/></xsl:attribute>
    <xsl:attribute name="estado"><xsl:value-of select="$addressState"/></xsl:attribute>
    <xsl:attribute name="pais"><xsl:value-of select="$addressCountry"/></xsl:attribute>
    <xsl:attribute name="codigoPostal"><xsl:value-of select="$addressZip"/></xsl:attribute>


  </xsl:element>

</xsl:element>

我正在使用Internet Explorer 10进行处理。稍后,我将此代码移植到Linux中并使用$ xsltproc运行它。

<bfr5:remision xmlns:bfr5="http://www.buzonfiscal.com/ns/xsd/bf/remision/52" version="5.2">
  <bfr5:infobasica folio="19190" refid="19190" rfcreceptor="XAXX010101000" rfcemisor="DLM131002M75" asignafolio="false">
    <infoespecial valor="19190" atributo="Invoice Number"></infoespecial>
    <bfr5:infoadicional lugarexpedicion="Mexico DF" tipodecomprobante="ingreso" metododepago="Transferencia electrónica de fondos" total="2.00" subtotal="2.00" formadepago="Pago en una sola Exhibición">
      <bfr5:emisor>
        <bfr5:regimenfiscal regimen="SCRAMBLE l De Ley Personas Morales"></bfr5:regimenfiscal>
        <bfr5:domiciliofiscal codigopostal="111950" pais="MEXICO" estado="D.F" municipio="SCRAMBLED CITY" calle="SCRAMBLE ADDRESS"></bfr5:domiciliofiscal>
      </bfr5:emisor>
    </bfr5:infoadicional>
 </bfr5:infobasica>
</bfr5:remision>

0 个答案:

没有答案