Hopefully the compilation at the bottom of this
message should make clear what I'm after.
But to be explicit, what do I put after
xpath-default-namespace=
in the <xsl:stylesheet ... /> to retrieve the namespace used
in source document.
-regards,
Larry
---{compilation---
compilation; default-directory: "/home/evansl/prog_dev/xslt/sandbox/" -*-
Compilation started at Fri Apr 11 17:05:57
make -k
cat ./inp/defaultns.html
<!--?xml version="1.0" encoding="utf-8"?-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--Example of using default namespace -->
<html xml:lang="en" xmlns="xxx" lang="en">
<head>
<title>default namespace .html</title>
</head>
<body>
<address>Nowhere</address>
</body>
</html>
cat ./xfm/defaultns.xml
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="xxx"
><!--How to avoid this hardcoding of xpath-default-namespace?-->
<xsl:template match="html">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
<xsl:text>@lang=</xsl:text>
<xsl:value-of select="@lang"/>
<xsl:text>
</xsl:text>
<xsl:text>@xmlns=</xsl:text>
<xsl:value-of select="namespace::*[name() eq '']"/>
</xsl:template>
</xsl:stylesheet>
/home/evansl/dwnlds/oracle/jdk_8_nb_8/install.dir/jdk1.8.0/bin/java -cp
/home/evansl/dwnlds/saxon/9.5/saxon9he.jar net.sf.saxon.Transform
-xsltversion:2.0 -T -s:inp/defaultns.html -xsl:./xfm/defaultns.xml
-o:out/defaultns.defaultns.html
<trace saxon-version="9.5.1.5"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<source node="/html" line="5" file="defaultns.html">
<xsl:template match="html" line="7" module="defaultns.xml">
<xsl:copy-of line="8" module="defaultns.xml">
</xsl:copy-of>
<xsl:text line="9" module="defaultns.xml">
</xsl:text>
<xsl:text line="11" module="defaultns.xml">
</xsl:text>
<xsl:value-of line="12" module="defaultns.xml">
</xsl:value-of>
<xsl:text line="13" module="defaultns.xml">
</xsl:text>
<xsl:text line="15" module="defaultns.xml">
</xsl:text>
<xsl:value-of line="16" module="defaultns.xml">
</xsl:value-of>
</xsl:template>
</source><!-- /html -->
</trace>
cat out/defaultns.defaultns.html
<?xml version="1.0" encoding="UTF-8"?><html xmlns="xxx" xml:lang="en"
lang="en"><head><title>default namespace .html</title></head><body>
<address>Nowhere</address>
</body></html>
@lang=en
@xmlns=xxx
Compilation finished at Fri Apr 11 17:05:59
---}compilation---
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--