|
Subject:
|
Help with XSLT: xmi:type="{@xmi:type}" (plz help)
|
|
Posted By:
|
WallaceHorta
|
Post Date:
|
8/18/2006 10:21:09 AM
|
In the sample below, the code xmi:type="{@xmi:type}" always generates the error "javax.xml.transform.TransformerException: Prefix must resolve to a namespace: xmi" How can i solve this (how can i get the value of a attribute named "@xmi:type") ?
(name="{@name}" works fine, the only problem is the xmi:type="{@xmi:type}")
Plz help, i really need this :-p
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" encoding="UTF-8"/> <xsl:template match="ownedMember"> <ownedMember name="{@name}" xmi:type="{@xmi:type}"/> </xsl:template> </xsl:stylesheet>
|
|
Reply By:
|
mhkay
|
Reply Date:
|
8/18/2006 10:49:24 AM
|
You need to declare the namespace in your stylesheet, e.g.
xmlns:xmi="http://some.namespace.uri/"
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
WallaceHorta
|
Reply Date:
|
8/18/2006 11:18:10 AM
|
Ty very much Mr. Michael Kay, now it works! (xmlns:xmi="http://schema.omg.org/spec/XMI/2.1")
However, plz help me with this colateral effect:
Using the code: <xsl:template match="ownedMember"> <ownedMember name="{@name}" xmi:type="{@xmi:type}"/> </xsl:template>
I am getting the result: <ownedMember xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmi:type="uml:DataType" name="String"/>
Well, i dont want the "xmlns:xmi" attribute to be coppied to any <ownedMember> tag it generates. The proper result would be <ownedMember xmi:type="uml:DataType" name="String"/>
Any way to fix this?
Ty again!
|
|
Reply By:
|
mhkay
|
Reply Date:
|
8/18/2006 11:23:06 AM
|
If your output has an attribute named xmi:type, then it must declare the xmi namespace, otherwise it wouldn't be valid XML output.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|