I have this simple xml document:
<?xml version='1.0' encoding='UTF-8'?>
<registry xmlns="http://www.iana.org/assignments" id="character-sets">
<registry id="character-sets-1">
<record>
<name>ANSI_X3.4-1968</name>
</record>
</registry>
</registry>
When I use this xsl I can extract the name:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://www.iana.org/assignments" version="1.0">
<xsl:template match="/my:registry">
<xsl:copy-of select="//my:record/my:name"/>
</xsl:template>
</xsl:stylesheet>
However, If I omit the namespace in the xsl xpath-selectors, I get no output:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="http://www.iana.org/assignments" xpath-default-namespace="http://www.iana.org/assignments" version="1.0">
<xsl:template match="/registry">
<xsl:copy-of select="//record/name"/>
</xsl:template>
</xsl:stylesheet>
I thought xpath-default-namespace is meant to do the trick. What am I missing?
In case library versions are important I have
libexpat1 (>= 1.95.8)
libxerces-c3.1
libxml2 (>= 2.7.4)
libxslt1.1 (>= 1.1.25)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…