Announcement

Collapse
No announcement yet.

xsltproc: Änderung beim Kopieren von Namespaces

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • xsltproc: Änderung beim Kopieren von Namespaces

    Hallo,

    Ich habe ein Problem beim Kopieren von Namespaces. Wenn ich das Stylesheet "example.xsl" auf das File "example.xml" anwende, gibt xsltproc in der Version 1.1.12 "Resultat 1" aus: Der Namespace xmlns:zyssql="http://www.example.ch/xmlns/0.0/zys/dbms/sql" wird in den root-Knoten kopiert (Resultat 1, Zeile 03). Der selbe Vorgang führt mit xsltproc Version 1.1.24 zu Resultat 2. Der besagte Namespace wird in den Knoten geschrieben, in welchem das entsprechende Attribut definiert ist (Resultat 2, Zeile 06). Ich benötige aber für die weitere Verarbeitung Resultat 1. Wie kriege ich das hin?

    Vielen Dank, Michael

    example.xml
    Code:
    01 <?xml version="1.0" encoding="UTF-8"?>
    02 <sp:masks xmlns:sp="http://www.example.ch/xmlns/0.0/zys/forms" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:zysdbs="http://www.example.ch/xmlns/0.0/zys/dbms/dbschema" xmlns:zyssql="http://www.example.ch/xmlns/0.0/zys/dbms/sql">
    03 <sp:mask id="sbs-sbsanreden-list-mask" frame="list">
    04 </sp:mask>
    05 <sp:mask id="sbs-sbsanreden-edit-mask" frame="page">
    06 <?xml-stylesheet href="../../../script/example.css" type="text/css"?>
    07 <xul:window id="sbs-sbsanreden-edit" zysdbs:lang="de">
    08 <xul:vbox class="scrollable" flex="1">
    09 <zysdbs:fields>
    10 <zysdbs:field zyssql:notnull="true"/>
    11 </zysdbs:fields>>
    12 </xul:vbox>
    13 </xul:window>
    14 </sp:mask>
    15 </sp:masks>
    example.xsl
    Code:
    01 <?xml version="1.0" encoding="iso-8859-1"?>
    02 <xsl:stylesheet
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:sp="http://www.example.ch/xmlns/0.0/zys/forms"
       version="1.0"
       xmlns:exsl="http://exslt.org/common"
       extension-element-prefixes="exsl"
       >
    03 <xsl:param name="path" select="'temp'" />
    04
    05 <xsl:output method="xml" indent="yes" />
    06 <xsl:template name="ignoreWhatever" priority="0.6" match="node()|@*">
    07   <xsl:apply-templates select="node()|@*" />
    08 </xsl:template>
    09
    10 <xsl:template name="copyPI" priority="0.7" match="processing-instruction()" mode="copy">
    11   <xsl:copy-of select="." />
    12 </xsl:template>
    13
    14 <xsl:template name="copyWhatever" priority="0.6" match="node()|@*" mode="copy">
    15   <xsl:copy>
    16     <xsl:apply-templates select="node()|@*" mode="copy" />
    17   </xsl:copy>
    18 </xsl:template>
    19 
    20 <xsl:template match="//sp:mask[@frame='page']" priority="1">
    21   <xsl:apply-templates mode="copy"/>
    22 </xsl:template>
    23
    24 <xsl:template match="/" priority="1">
    25 <xsl:apply-templates />
    26   <dummy-root/>
    27 </xsl:template>
    28
    29 </xsl:stylesheet>
    Resultat 1: xsltproc v1.1.12 (Using libxml 20616, libxslt 10112 and libexslt
    810)
    Code:
    01 <?xml version="1.0"?>
    02 <?xml-stylesheet href="../../../script/example.css" type="text/css"?>
    03 <xul:window xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:zysdbs="http://www.example.ch/xmlns/0.0/zys/dbms/dbschema" xmlns:zyssql="http://www.example.ch/xmlns/0.0/zys/dbms/sql" id="sbs-sbsanreden-edit" zysdbs:lang="de">
    04 <xul:vbox class="scrollable" flex="1">
    05 <zysdbs:fields>
    06 <zysdbs:field zyssql:notnull="true"/>
    07 </zysdbs:fields>&gt;
    08 </xul:vbox>
    09 </xul:window>
    10 <dummy-root xmlns:sp="http://www.example.ch/xmlns/0.0/zys/forms"/>
    Resultat 2: xsltproc v1.1.24 (Using libxml 20632, libxslt 10124 and libexslt
    813)
    Code:
    01 <?xml version="1.0"?>
    02 <?xml-stylesheet href="../../../script/example.css" type="text/css"?>
    03 <xul:window xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:zysdbs="http://www.example.ch/xmlns/0.0/zys/dbms/dbschema" id="sbs-sbsanreden-edit" zysdbs:lang="de">
    04 <xul:vbox class="scrollable" flex="1">
    05 <zysdbs:fields>
    06 <zysdbs:field xmlns:zyssql="http://www.example.ch/xmlns/0.0/zys/dbms/sql" zyssql:notnull="true"/>
    07 </zysdbs:fields>
    08 </xul:vbox>
    09 </xul:window>
    10 <dummy-root xmlns:sp="http://www.example.ch/xmlns/0.0/zys/forms"/>

  • #2
    Sinnvoll ist es vermutlich, einen Bugreport für xsltproc zu erstellen, so das eine aktuelle Version ist.
    Ansonsten kannst du versuchen, "namespace nodes" (Namensraumknoten) explizit zu kopieren:
    Code:
    <xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:sp="http://www.example.ch/xmlns/0.0/zys/forms"
        version="1.0"
        xmlns:exsl="http://exslt.org/common"
        extension-element-prefixes="exsl">
      <xsl:param name="path" select="'temp'" />
      <xsl:output method="xml" indent="yes" />
      <xsl:template name="ignoreWhatever" priority="0.6" match="node()|@*">
        <xsl:apply-templates select="node()|@*" />
      </xsl:template>
      <xsl:template name="copyPI" priority="0.7" match="processing-instruction()" mode="copy">
        <xsl:copy-of select="." />
      </xsl:template>
      <xsl:template name="copyWhatever" priority="0.6" match="node()|@*" mode="copy">
        <xsl:copy>
          <xsl:apply-templates select="node()|@*" mode="copy" />
        </xsl:copy>
      </xsl:template>
      <xsl:template match="sp:mask[@frame='page']/*" mode="copy" priority="0.6">
        <xsl:copy>
          <xsl:copy-of select="namespace::*"/>
          <xsl:apply-templates select="@*|node()" mode="copy"/>
        </xsl:copy>
      </xsl:template>
      <xsl:template match="//sp:mask[@frame='page']" priority="1">
        <xsl:apply-templates mode="copy"/>
      </xsl:template>
      <xsl:template match="/" priority="1">
        <xsl:apply-templates />
        <dummy-root/>
      </xsl:template>
    </xsl:stylesheet>
    dann werden aber auch Dinge wie xhtml und sp Deklarationen kopiert werden.

    Comment

    Working...
    X