[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Changing prefix

Subject: Re: Changing prefix
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 19 May 2004 15:59:04 -0400
math prefixes
Nicolas,

David (Dr MathML) will probably be along shortly, but....

As you may know, XSLT (or any XML-namespace-conformant system) doesn't distinguish between elements on the basis of their prefixes, but on the basis of the expanded name when those prefixes are resolved to their URI bindings. So if you have

<example xmlns:n1="myURL.com" xmlns:n2="myURL.com">
  <n1:element/>
  <n2:element/>
</example>

n1:element and n2:element are considered to be the same.

What this means is that you really only need an identity transform that writes your output using the prefix you want.

This can probably be done (although I haven't tried it) very simply:

<xsl:stylesheet  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:math="http://www.w3.org/1998/Math/MathML ">

<xsl:template match="/">
  <xsl:copy-of select="/"/>
</xsl:template>

</xsl:stylesheet>

This will work since the "math" prefix here is bound to the same URI as the "mml" prefix in your input. (I'm assuming your input declares the correct namespace. :-) And most XSLT engines should serialize the result using the prefix you have chosen, "math". (Note however that strictly speaking they don't have to do this: in effect you are relying on an optional feature of the serializer, and you should test the technique on any processor before depending on its working there.)

Cheers,
Wendell

At 03:53 PM 5/19/2004, you wrote:
 I have an app that uses MathML, and gathers some stats from it.
 But i ran into a problem when using mml tags embedded in docbook,
 as this app uses the "math" prefix, and in docbook mathml tags
 are prefixed with "mml".

 I am trying to do a stylesheet that copies all mathml elements,
 including attributes, data etc.. just changing the prefix.

 Any idea ?
 Nicolas


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.