Davinod
Davinod

Reputation: 21

How to make XSL not convert my xsl:element and xsl:attribute names to lowercase?

Hello StackOverFlow community,

I have created a simple XSL to convert a XML file into another.

The output XML file needs to follow a schema that I received from a vendor which describes its elements following camelCase standard.

for instance, I need to create the element:

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

However, when I run my XSL, it changes the element and attribute names all to lowercase.

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

This is the entire XSL file:

<?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>

I'm using Internet Explorer 10 to process. Later, I will port this code into Linux and run it using $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>

Upvotes: 1

Views: 92

Answers (1)

Davinod
Davinod

Reputation: 21

Ok - It seems this is happening because of Internet Explorer.

I have ported the XSL and XML into Linux and run via xsltproc. It no longer turns the element and attribute names into lowercase. It keeps my camelCase now.

Regards, Davi

Upvotes: 1

Related Questions