2016-09-29 9 views
0

all。私は本当に大きな問題を抱えています。私は情報を求めています。 IveはJavaでプロジェクトを手に入れました。このプロジェクトの機能の1つは、xlsを解析する必要があるということです。まあ、それを解析する際にiveに問題がありました。これはxslsを解析ループです:XSL、javax.xml.transform.TransformerExceptionをコンパイル中に問題が発生しました:

while(itera.hasNext()){ 
     // Creacion del transformador de SAX 
      tFactory.setErrorListener(new ManejadorXSLTErrores()); 
      String nombrePlantilla = (String)itera.next(); 
      //creamos el objeto transformer 
      String stream = (String)plantillas.get(nombrePlantilla); 
      if((stream!= null) && (getClass()!=null) && (getClass().getResourceAsStream(stream)!=null)) 
       reader = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(stream))); 
      else 
       throw new ExceptionErrorARQSD(ConstantesErrorSD.ERROR_XML_TRANSFORMACION,new String[]{"Error al obtener el StreamSource: "+stream},null); 
      transformer = tFactory.newTemplates(new StreamSource(reader)); 
      //se guardan en un contenedor 
      contenedortransformers.putElemento(nombrePlantilla,transformer); 
     } 

そして、これは私のエクセルのXSDの一部です:

<?xml version="1.0" encoding="UTF-8"?> 
       <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt"> 

       <xsl:param name="servicio"> 
        <xsl:value-of select="normalize-space(/SD/MENSAJECM/contenedorPeticionDatosComunes/codigoServicio)"/> 
       </xsl:param> 
     <xsl:template match="/"> 
       <xsl:apply-templates/> 
      </xsl:template> 


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



      <xsl:template match="MENSAJECM"> 
       <xsl:if test="$servicio = 'NSPLA001'"> 
        <xsl:element name="MensajeSolicitud"> 
         <xsl:apply-templates/> 
        </xsl:element> 
       </xsl:if> 
       <xsl:if test="$servicio = 'NSPLA002'"> 
        <xsl:apply-templates/> 
       </xsl:if> 
      </xsl:template> 

    <xsl:template match="contenedorPeticionDatosComunes"> 
      <xsl:if test="$servicio = 'NSPLA001'"> 
       <xsl:param name="fecha"><xsl:value-of select="normalize-space(./fecha)"/></xsl:param> 
       <xsl:param name="hora"><xsl:value-of select="normalize-space(./hora)"/></xsl:param> 
       <!-- Cod. Entidad U.O.R. (csbc) --> 
       <xsl:attribute name="csbc"> 
        <xsl:value-of select="substring(./unidadOrganizativaResponsable,1,4)"/> 
       </xsl:attribute> 

       <xsl:attribute name="fecha_envio"> 
        <xsl:value-of select="$fecha"/> 
       </xsl:attribute> 

       <xsl:attribute name="oficina"> 
        <xsl:value-of select="substring(./unidadOrganizativaResponsable,5,4)"/> 
       </xsl:attribute> 

       <xsl:attribute name="terminal"> 
        <xsl:value-of select="substring(./unidadOrganizativaResponsable,11,2)"/> 
       </xsl:attribute> 

       <xsl:attribute name="usuario"> 
        <xsl:value-of select="./usuario"/> 
       </xsl:attribute> 

       <xsl:attribute name="version"> 
        <xsl:value-of select="1.0"/> 
       </xsl:attribute> 
      </xsl:if> 
     </xsl:template> 
</xsl:stylesheet> 

これは私が受け取る例外です:

javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: ¡xsl:param no está permitido en esta posición de la hoja de estilos! 
javax.xml.transform.TransformerException: ¡xsl:param no está permitido en esta posición de la hoja de estilos! 

誰でも私を助けることができますか?おかげ

+0

をそれがの直接の子でなければならない場合スタイルシートまたはテンプレートが必要であり、最初のものでなければなりません。 http://stackoverflow.com/questions/7378859/usage-of-xslt-params-xslparam-xslwith-param少なくとも私はそれをどのように読んでいるのですか? – Rob

+0

Rob、あなたの意見では、xslは正しくありませんか?私はこのxslを作成しませんでした。 – Dekker

答えて

0

おかげでロブは、特別にあなたの助けのために、XLSは十分に形成されていない:私はこの方法のようにコメントしている場合

<xsl:template match="contenedorPeticionDatosComunes"> 
     <!-- <xsl:if test="$servicio = 'NSPLA001'"> --> 
      <xsl:param name="fecha"><xsl:value-of select="normalize-space(./fecha)"/></xsl:param> 
      <xsl:param name="hora"><xsl:value-of select="normalize-space(./hora)"/></xsl:param> 
      <!-- Cod. Entidad U.O.R. (csbc) --> 
      <xsl:attribute name="csbc"> 
       <xsl:value-of select="substring(./unidadOrganizativaResponsable,1,4)"/> 
      </xsl:attribute> 
      <!-- Fecha Envío --> 
      <xsl:attribute name="fecha_envio"> 
       <xsl:value-of select="$fecha"/> 
      </xsl:attribute> 
      <!-- Cod. Oficina U.O.R. --> 
      <xsl:attribute name="oficina"> 
       <xsl:value-of select="substring(./unidadOrganizativaResponsable,5,4)"/> 
      </xsl:attribute> 
      <!-- Cod. Terminal U.O.R. --> 
      <xsl:attribute name="terminal"> 
       <xsl:value-of select="substring(./unidadOrganizativaResponsable,11,2)"/> 
      </xsl:attribute> 
      <!-- Id Usuario --> 
      <xsl:attribute name="usuario"> 
       <xsl:value-of select="./usuario"/> 
      </xsl:attribute> 
      <!-- Version --> 
      <xsl:attribute name="version"> 
       <xsl:value-of select="1.0"/> 
      </xsl:attribute> 
     <!-- </xsl:if> --> 
    </xsl:template> 

は、今、私はxslsを解析しながら、ループ内の任意のエラーを受け取るいけません。

1

右ので、それはそこにあなたはこの試みる使用する必要がある場合に動作させるために:XSL下のparam::私はあなたがXSLを持つことができると信じていない

<?xml version="1.0" encoding="UTF-8"?> 
       <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt"> 

       <xsl:param name="servicio"> 
        <xsl:value-of select="normalize-space(/SD/MENSAJECM/contenedorPeticionDatosComunes/codigoServicio)"/> 
       </xsl:param> 
     <xsl:template match="/"> 
       <xsl:apply-templates/> 
      </xsl:template> 


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



      <xsl:template match="MENSAJECM"> 
       <xsl:if test="$servicio = 'NSPLA001'"> 
        <xsl:element name="MensajeSolicitud"> 
         <xsl:apply-templates/> 
        </xsl:element> 
       </xsl:if> 
       <xsl:if test="$servicio = 'NSPLA002'"> 
        <xsl:apply-templates/> 
       </xsl:if> 
      </xsl:template> 

    <xsl:template match="contenedorPeticionDatosComunes"> 
      <xsl:param name="fecha"><xsl:value-of select="normalize-space(./fecha)"/></xsl:param> 
      <xsl:param name="hora"><xsl:value-of select="normalize-space(./hora)"/></xsl:param> 
      <xsl:if test="$servicio = 'NSPLA001'"> 
       <!-- Cod. Entidad U.O.R. (csbc) --> 
       <xsl:attribute name="csbc"> 
        <xsl:value-of select="substring(./unidadOrganizativaResponsable,1,4)"/> 
       </xsl:attribute> 

       <xsl:attribute name="fecha_envio"> 
        <xsl:value-of select="$fecha"/> 
       </xsl:attribute> 

       <xsl:attribute name="oficina"> 
        <xsl:value-of select="substring(./unidadOrganizativaResponsable,5,4)"/> 
       </xsl:attribute> 

       <xsl:attribute name="terminal"> 
        <xsl:value-of select="substring(./unidadOrganizativaResponsable,11,2)"/> 
       </xsl:attribute> 

       <xsl:attribute name="usuario"> 
        <xsl:value-of select="./usuario"/> 
       </xsl:attribute> 

       <xsl:attribute name="version"> 
        <xsl:value-of select="1.0"/> 
       </xsl:attribute> 
      </xsl:if> 
     </xsl:template> 
</xsl:stylesheet> 
関連する問題