Как я могу предотвратить эти избыточные пространства имен от таблицы стилей XSLT?

Я выяснил проблему, получая доступ к конечной точке из VPN-соединения, открытого для AWS. Поэтому доступ к API пришел из AWS EC2, я не знаю почему, но когда я вышел из VPN, это сработало.

5
задан Ben Blank 6 May 2009 в 01:03
поделиться

2 ответа

Instead of xsl:copy-of use an identity transformation templates and remove the namespace prefix from XHTML elements.

<xsl:stylesheet version="1.0"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:fbb="urn:foo:bar:baz"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:html="http://www.w3.org/1999/xhtml"
                exclude-result-prefixes="fbb html">

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/fbb:foo">
    <html>
      <head>
        <title>Example</title>
      </head>
      <body>
        <p>
          <xsl:apply-templates select="fbb:bar/fbb:baz/node()"/>
        </p>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="html:*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@* | node()"/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
8
ответ дан 13 December 2019 в 05:41
поделиться

Update your exclude-result-prefixes to include the default namespace:

exclude-result-prefixes="#default"

Or you could suppress all inline namespacing by doing:

exclude-result-prefixes="#all"

There is a bit of wonkiness though, as some processors expect a space-separated list while others expect a comma-separated list. xsltproc seems to like comma-separated so if you still want to be explicit you can do:

exclude-result-prefixes="#default,fbb"
4
ответ дан 13 December 2019 в 05:41
поделиться
Другие вопросы по тегам:

Похожие вопросы: