select oder test-Anweisung Problem

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • select oder test-Anweisung Problem

    Hi,

    im Dokument existieren mehrere Präfixes, die über die Namespaces definiert sind. Mir ist aufgefallen, dass die select~ oder test-Anweisungen nicht richtig verarbeitet werden. Ziel ist es einen Exportfilter für ODF zu schreiben!

    Ich speichere einige Dateien in einer temporären Datei.

    Aufbau der File:

    Quellcode

    1. <styles>
    2. <office:document-styles>
    3. <style:style/>
    4. </office:document-styles>
    5. <office:automatic-styles>
    6. </style:style>
    7. </office:automatic-styles>
    8. <styles>


    Anfragen wie select="styles/*" gehen, aber Anfragen mit Präfixen wie select="styles/office:document-styles/style:style" gehen nicht. Nutze ich * als Wildcard geht es wieder. Das Problemen scheinen die Präfixe zu sein, habe zu Testzwecken mal Bezeichner ohne Präfixes in der Datei einfügt und da lief, aber so bald ein Präfix dazwischen kommt, geht nix mehr.
    Für Ideen bin ich dankbar

    Gruß Jens
  • hi,

    wie hast du die namespaces bekannt gemacht? Hier mal ein Beispiel, wie du es innerhalb des XSLT Stylesheets angibst.
    Nur so kann XPATH damit umgehen:

    Quellcode

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    3. xmlns:office="http://localhost/office"
    4. xmlns:style="http://localhost/style">
    5. <xsl:template match="/">
    6. <html><body>
    7. <xsl:value-of select="/styles/office:document-styles/style:style" />
    8. </body></html>
    9. </xsl:template>
    10. </xsl:stylesheet>
    Alles anzeigen
  • die namespaces

    Danke, für die fixe Antwort, hilft aber leider nicht.

    Hier ist der Teil der xsl-Datei, mit den Namespaces. Wenn ich die Namespaces nicht angegeben hätte, würde ich bereits bei der Erstellung eine Fehlermeldung bekommen, da ist mein Editor sehr genau.

    Quellcode

    1. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    2. xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style"
    3. xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table"
    4. xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    5. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle"
    6. xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart"
    7. xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML"
    8. xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script"
    9. xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta"
    10. xmlns:config="http://openoffice.org/2001/config" xmlns:help="http://openoffice.org/2000/help"
    11. xmlns:xt="http://www.jclark.com/xt" xmlns:common="http://exslt.org/common"
    12. xmlns:xalan="http://xml.apache.org/xalan" xmlns:exslt="http://exslt.org/common"
    13. xmlns:fn="http://www.w3.org/2005/xpath-functions"
    14. exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help xt common xalan">
    Alles anzeigen


    Die xpath-Anfragen habe ich auch schon getestet, sind ok. Aber beim Test mit mehreren Processoren AltovaXML 2008 und Saxon8B werden diese Formulierungen immer ignoriert!
  • ich glaube nicht, dass der Firefox das anders macht als deine Prozessoren. Da liegt bestimmt noch ein Unterschied im Dokument.

    Hier meine 2 Testfiles, wie sie vom Firefox interpretiert werden:

    Quellcode

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <?xml-stylesheet type="text/xsl" href="test.xsl"?>
    3. <styles xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    4. xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style"
    5. xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table"
    6. xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    7. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle"
    8. xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart"
    9. xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML"
    10. xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script"
    11. xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta"
    12. xmlns:config="http://openoffice.org/2001/config" xmlns:help="http://openoffice.org/2000/help"
    13. xmlns:xt="http://www.jclark.com/xt" xmlns:common="http://exslt.org/common"
    14. xmlns:xalan="http://xml.apache.org/xalan" xmlns:exslt="http://exslt.org/common"
    15. xmlns:fn="http://www.w3.org/2005/xpath-functions"
    16. exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help xt common xalan">
    17. <office:document-styles>
    18. <style:style>a</style:style>
    19. </office:document-styles>
    20. <office:automatic-styles>
    21. <style:style>b</style:style>
    22. </office:automatic-styles>
    23. </styles>
    Alles anzeigen


    Quellcode

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    3. xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style"
    4. xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table"
    5. xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format"
    6. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:number="http://openoffice.org/2000/datastyle"
    7. xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart"
    8. xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML"
    9. xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script"
    10. xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta"
    11. xmlns:config="http://openoffice.org/2001/config" xmlns:help="http://openoffice.org/2000/help"
    12. xmlns:xt="http://www.jclark.com/xt" xmlns:common="http://exslt.org/common"
    13. xmlns:xalan="http://xml.apache.org/xalan" xmlns:exslt="http://exslt.org/common"
    14. xmlns:fn="http://www.w3.org/2005/xpath-functions"
    15. exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help xt common xalan">
    16. <xsl:template match="/">
    17. <html><body>
    18. <xsl:value-of select="/styles/office:document-styles/style:style" />
    19. </body></html>
    20. </xsl:template>
    21. </xsl:stylesheet>
    Alles anzeigen