xsl-list
[Top] [All Lists]

Re: [xsl] another namespace question

2009-01-14 14:18:08
Hi everyone, I figured it out. Or at least one solution, probably the right one. I put the code for the second file in a different xsl document and imported it, so I was able to make a different namespace declaration at the top. Maybe I am getting closer to figuring this out. Thanks for the help!

Fred Christian wrote:
I asked this question before, but I didn't have a clean example ( I am liking Kernow more and more). I am wondering if there is a way to (how to) write some xslt that has two output files with different namespace declarations. My example input, xslt, and 2 output files are below.

My default output file is working correctly. It has this at the top <html "xmlns="http://www.w3.org/1999/xhtml";> see ___Default output___ below. In my real code this output file is much bigger with lots of xslt that makes it. XSLT that I hope I don't have to change.

In the second output file _anotherOutputFile.xml _,
I would like to find a way for it to not have a namespace declaration in any of the subnodes.

Can you help?

______   Input   XML  ____________________
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<DD>
   <this>The Theta character &#x3B8;</this>
   <that>A non math character &#0931;</that>
   <that>A non math character &#x2248;</that>
</DD>

____________ XSLT __________________
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns="http://www.w3.org/1999/xhtml";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output encoding="UTF-8" indent="yes" method="xml"/>
<xsl:output encoding="iso-8859-1" method="xml" indent="yes" name="xml"/>

<xsl:template match="DD">
<xsl:result-document href="{'anotherOutFile.xhtml'}" format="xml" indent="yes">
       <xsl:copy>
           <xsl:apply-templates mode="copythat"/>
       </xsl:copy>
   </xsl:result-document>      <html> a bunch of stuff goes here. </html>
</xsl:template>

<xsl:template match="text()" mode="copythat">
<xsl:analyze-string select="." regex="\p{{IsMathematicalOperators}}|(&#0931;)"> <xsl:matching-substring><span class="Symbol"><xsl:value-of select="."/></span></xsl:matching-substring> <xsl:non-matching-substring><xsl:value-of select="."/></xsl:non-matching-substring>
   </xsl:analyze-string>
</xsl:template>

<xsl:template match="*" mode="copythat">
<xsl:copy><xsl:copy-of select="@*"/><xsl:apply-templates mode="copythat"/></xsl:copy>
</xsl:template>

</xsl:stylesheet>
--------------------------------------------

_______  Default output  ______________
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml";>
  <body>a bunch of stuff <i>goes here</i>.</body>
</html>
--------------------------------------------

____    anotherOutputFile.xml  _________
<?xml version="1.0" encoding="iso-8859-1"?>
<DD>
     <this>The Theta character &#952;</this>
<that>A non math character <span xmlns="http://www.w3.org/1999/xhtml"; class="Symbol">&#931;</span>
  </that>
<that>A non math character <span xmlns="http://www.w3.org/1999/xhtml"; class="Symbol">&#8776;</span>
  </that>
</DD>
--------------------------------------------

____  What I wish   anotherOutputFile.xml   looked like _________
<?xml version="1.0" encoding="iso-8859-1"?>
<DD>
     <this>The Theta character &#952;</this>
     <that>A non math character <span>&#931;</span>
  </that>
     <that>A non math character <span>&#8776;</span>
  </that>
</DD>
--------------------------------------------


--~------------------------------------------------------------------
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>
--~--


--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>