Namespaces in XSL
Hi ppl!
When I use some additional xmlns in XSL it appears in output tag. For example:
****************************[XSL file]************************************
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my-ext="http://www.oracle.com/XSL/Transform/java/tbl.execJS"
xsl:exclude-result-prefixes="my-ext">
<xsl:output method="html"/>
</xsl:stylesheet>
****************************[HTML output]*********************************
<html xmlns:my-ext="http://www.oracle.com/XSL/Transform/java/tbl.execJS">
</html>
How can I get rid of this notation in output?
Thanks before
Hi,
Sorry, I should have included this on original posting.
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema targetNamespace="http://mycompany.co.uk/WorkOrderLabourHours.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="WorkOrderLabourHours">
<xs:complexType>
<xs:choice>
<xs:element name="EllipseEvent">
<xs:complexType>
<xs:sequence>
<xs:element name="ConfigData">
<xs:complexType>
<xs:all>
<xs:element name="DateTimeStamp" type="xs:string"/>
<xs:element name="DstrctCode" type="xs:string"/>
<xs:element name="User" type="xs:string"/>
<xs:element name="Position" type="xs:string"/>
<xs:element name="Host" type="xs:string"/>
<xs:element name="Port" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:choice>
<xs:element name="EllipseRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="ControlData">
<xs:complexType>
<xs:attribute name="Object"
type="xs:string"/>
<xs:attribute name="Method"
type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="LabourHoursData">
<xs:complexType>
<xs:all>
<xs:element name="WorkOrder" type="xs:string"/>
<xs:element name="TransactionDate"
type="xs:string"/>
<xs:element name="EmployeeId1" type="xs:string"/>
<xs:element name="Minutes1" type="xs:string"/>
<xs:element name="EarningsClass1" type="xs:string"/>
<xs:element name="WoTaskNo1" type="xs:string"/>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="ReplyData">
<xs:complexType>
<xs:sequence>
<xs:element name="Error" type="xs:string"/>
<xs:element name="DstrctCode" type="xs:string"
minOccurs="0"/>
<xs:element name="WorkOrder" type="xs:string"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="EventType" form="qualified" type="xs:string"
use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Similar Messages
-
What is the best way to change a namespace in an xml document
Hi,
I need to change an xml namespaces. The xml has about 200 elements and every element may have a namespace attribute (namespaces are all the same).
Is there any better solution then the following function?
SQL> create or replace function change_namespace(p_xml xmltype, p_namespace varchar2) return xmltype is
2 l_doc dbms_xmldom.DOMDocument;
3 l_nodes dbms_xmldom.DOMNodelist;
4 l_node dbms_xmldom.DOMNode;
5 begin
6 l_doc:=dbms_xmldom.NewDOMDocument(p_xml);
7 l_nodes:=dbms_xmldom.getElementsByTagName(l_doc,'*');
8 for i in 0..dbms_xmldom.getlength(l_nodes)-1 loop
9 l_node:=dbms_xmldom.item(l_nodes,i);
10 if i=0 then
11 --set namespace only for the root node
12 dbms_xmldom.setattribute(dbms_xmldom.makeElement(l_node),'xmlns',p_namespace);
13 else
14 --remove all the other namespaces
15 dbms_xmldom.removeattribute(dbms_xmldom.makeElement(l_node),'xmlns');
16 end if;
17 end loop;
18
19 return dbms_xmldom.getxmltype(l_doc);
20 end;
21 /
Function created.
SQL> select change_namespace(xmltype('<a xmlns="aaa"><b xmlns="aaa">4</b><c>44</c></a>'),'newnamespace')
2 from dual;
CHANGE_NAMESPACE(XMLTYPE('<AXMLNS="AAA"><BXMLNS="AAA">4</B><C>44</C></A>'),'NEWN
<a xmlns="newnamespace">
<b>4</b>
<c>44</c>
</a> AntsHi,
I found a better and almost 10x faster way to remove the namespaces, using xsl.
here's the original xsl with a little modifications http://bytes.com/forum/thread448445.html
SQL> with t as (select xmltype('<a xmlns="aaa"><b xmlns="aaa">4</b><c>44</c></a>') xcol from dual)
2 select xmltransform(xcol
3 ,xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
4 <xsl:template match="*">
5 <xsl:element name="{local-name()}" namespace="">
6 <xsl:apply-templates select="@* | node()" />
7 </xsl:element>
8 </xsl:template>
9 </xsl:stylesheet>'))
10 from t;
XMLTRANSFORM(XCOL,XMLTYPE('<XSL:STYLESHEETVERSION="1.0"XMLNS:XSL="HTTP://WWW.W3.
<a><b>4</b><c>44</c></a>+but check Laurents Schneider's blog website+
I didn't find any posts about namespace on Schneider's blog.
Ants -
Oracle.xml.parser.v2.XSLException: XSL-1045
I'm trying to migrate from 8.1.6 to 8.1.7. In 8.1.6, I have a working java stored procedure that implements an extended namespace in XSL. I deployed the same working code in 8.1.7 and got the following error.
processor.processXSL(styleSheet,xmlDoc)>>
oracle.xml.parser.v2.XSLException: XSL-1045:
Extension function error: Class not found 'com/redknife/util/xslExtend'
The xslExtend class is loaded via loadjava and resolves with no errors. Is there a difference between the 8.1.6 implementation and 8.1.7?
- CraigI've recreated the database and the instance...I've loaded all the classes and they are valid... The exact code set works in 8.1.6 but not in 8.1.7.
Here lies the difference. In 8.1.6, I loaded the xmlparserv2.jar, but hoping for the natively compiled version being preloaded in 8.1.7, I did not load it. The error then occurs. I did a dropjava on the xmlparserv2.jar, and then a loadjava, and now it works.
My assumption is that it was the natively compiled xml parser that made the difference. Once I removed it, and replaced it with byte code, everything worked.
Hope I'm wrong... Craig -
Namespace issue while generating XML based on xsd
Hi All,
I am using Jdeveloper-11.1.1.6
SOA:- 11.1.1.6
WLS:- 11.3.6
When i am publishing xml message i am getting name space issue.
My process design as i am getting a message from AQ JMS and doing a transformation with out any logic and writing into a file based on the xsd.
Here is the my target xsd structure
<xs:schema id="RelieveIntransitSchema"
targetNamespace="http://tempuri.org/RelieveIntransitSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/RelieveIntransitSchema.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="RelieveIntransits">
<xs:complexType>
<xs:sequence>
<xs:element name="RelieveIntransit" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="RelieveStore" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence></xs:sequence>
<xs:attribute name="StoreID" type="xs:string"/>
<xs:attribute name="Units" type="xs:double"/>
<xs:attribute name="RelieveAllStores" type="xs:boolean"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="HeaderID" type="xs:string" use="optional"/>
<xs:attribute name="ProductID" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
My actual target xml should be of
<?xml version="1.0"?>
<RelieveIntransits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/RelieveIntransitSchema.xsd">
<RelieveIntransit HeaderID="DA41198901491301" ProductID="D037-63-1270S">
<RelieveStore StoreID="D001" Units="0002092 " />
<RelieveStore StoreID="D003" Units="0000022 " />
</RelieveIntransit>
</RelieveIntransits>
But the out xml generating as below which is not accepted by target system
<?xml version="1.0" encoding="UTF-8"?>
<RelieveIntransits xmlns="http://tempuri.org/RelieveIntransitSchema.xsd" xmlns:ns5="http://tempuri.org/RelieveIntransitSchema.xsd"> <ns5:RelieveIntransit ProductID="6534562" HeaderID="10R7771-6534562001-109"> <ns5:RelieveStore Units="5" StoreID="118"/>
<ns5:RelieveStore Units="5" StoreID="118"/>
</ns5:RelieveIntransit>
</RelieveIntransits>
Could some one please help me how to generate actual one as shown above with out namespace prefix "ns". I tried xsl code for removing name space prefix using https://forums.oracle.com/forums/thread.jspa?threadID=1122673 but it is removing url also.
Regards,
Tarak
Edited by: Tarak on Jul 26, 2012 11:39 AMHi,
Sorry for my delay response.
Both xmls are valid and equivalent for me... should be equivalent to <ns1:a xmlns:ns1="namespace"/>...
I agree to your point.
What is your target system? If that makes difference for your target system I would say it is not fully XML compliant...
Target system is an old one called as MID. Yes i agree it is not fully XML Compliant. I am publishing the message through file adapter and it is reading the file.
But anyway... The trick in the other thread should work... What do you mean by "removing url also" ???
Using the Namespaces remove xsl code i am getting structure as below. In this alone with prefix name space url also getting removed.
<RelieveIntransits>
<RelieveIntransit HeaderID="DA41198901491301" ProductID="D037-63-1270S">
<RelieveStore StoreID="D001" Units="0002092 " />
</RelieveIntransit>
</RelieveIntransits>
I am expecting like this
<?xml version="1.0"?>
<RelieveIntransits xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/RelieveIntransitSchema.xsd">
<RelieveIntransit HeaderID="DA41198901491301" ProductID="D037-63-1270S">
<RelieveStore StoreID="D001" Units="0002092 " />
</RelieveIntransit>
</RelieveIntransits> -
Xmlanonymizer bean and xslt - both not working for namespace change
Hi All
I have a source structure below
<ns1:Product_MT xmlns:ns1="urn:alpha:websub" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
</Header>
<Item>
</Item>
</ns1:Product_MT>
I am using a soap sender getting called from SOAP UI to consume a PI web service and send the output message to receiver HTTP channel
the receiver needs the namespace of the XML structure as below (ns1 changed to ns)
<ns:Product_MT xmlns:ns="urn:alpha:websub" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
</Header>
<Item>
</Item>
</ns:Product_MT>
I tried to put the xmlanonymizer bean in receiver HTTP but its not doing anything. I am stil getting the output with ns1 namespace
Attached screenshot of receiver http adapter configuration in module
also, I tried to use XSLT mapping as below but this is also not doing anything. Probably, the XSL has to be modified to use in my case . Please help. and let me know.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<ns:Product_MT xmlns:ns="urn:alpha:websub">
<xsl:copy-of select="." />
</ns:Product_MT>
</xsl:template>
</xsl:stylesheet>
thx
mikeI had to tweak the XSL little bit to make it work in PI. See updated version below -
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="UTF-8" indent="yes" method="xml" version="1.0"/>
<xsl:variable name="root">MT_Product</xsl:variable>
<xsl:variable name="rootns">urn:mdt:udiwebsubmission</xsl:variable>
<xsl:template match="*">
<xsl:choose>
<xsl:when test="local-name()=$root">
<xsl:element name="ns:{local-name()}" namespace="{$rootns}">
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Regards,
Sameej -
XSLT with namespaces/schema
Hi everybody !
I've a problem transforming a XML file that has a root element containing a reference to a XSD schema.
<myxml xmlns="http://www.myxml.de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myxml.de myxml.xsd">
The XSLProcessor does not accept the attribute in the root element but always complains that to be empty :-((.
I was told, that one of the few processors that could handle Schema and namespaces was the Oracle v2 lib.
So I'm trying to transform with the following piece of code and ORACLE v2 parser lib:
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class SimpleTrAX
public static void main( String[] args )
try
File xslIn = new File( "D:/A.xslt" );
File xmlIn = new File( "D:/B.xml" );
File xmlOut = new File( "D:/C.xml" );
// System.setProperty( "javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
// System.setProperty( "javax.xml.parsers.DocumentBuilderFactory", "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl");
// System.setProperty( "javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
// System.setProperty( "javax.xml.parsers.SAXParserFactory", "org.apache.crimson.jaxp.SAXParserFactoryImpl");
// System.setProperty( "javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
xmlOut.createNewFile();
TransformerFactory transFact = TransformerFactory.newInstance();
StreamSource xslStream = new StreamSource( xslIn );
StreamSource xmlStream = new StreamSource( xmlIn );
FileOutputStream fileOut = new FileOutputStream( xmlOut );
StreamResult xmlResult = new StreamResult( fileOut );
Transformer trans = transFact.newTransformer( xslStream );
trans.transform( xmlStream, xmlResult );
catch (Exception e) { System.out.println( e ); }
I haven't found any attributes or properties to set the transformer or it's factory to be namespace aware. Any help or helpful hint will be highly appreciated ! Thanks in advance !
Best regards
JuergenThanks for your quick answer !
But including the namespace which is part of the root element in file A into the transforming stylesheet (as you proposed) that should produce result file C seems to
mislead the transformer:
It now validates the root tags of the transformation script against the wrong namespace/schema:
<xsl:stylesheet version="1.0"
xmlns="http://www.myxml.de"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myxml.de myxml.xsd"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="myxml"> <!-- Match root of source doc A -->
<root_of_result_document_C>
<!-- apply something else -->
</root_of_result_document_C>
</xsl:template>
</xsl:stylesheet>
I now get an error (comprehensible for me):
"Root element 'root_of_result_document_C' not defined in DTD/Schema"
??? -
Adding namespace to order xml received from B2B
Hi there,
I am receiving an order xml file from B2B.
The order xml file does not have the namespace and I need to add namespace to it.
Is there a way we can achieve this?
Flow is B2B Adapter -> Mediator -> BPEL - .....
I am trying to do this in the mediator transform.(http://www.velocityreviews.com/forums/t169875-help-cant-add-namespace-using-xsl.html) But it did not work.
Thanks in advance.
Rgds
GaneshYou can achive this by having a dummy 1-1 transformation, but there is a danger that the xslt processer might not be able to get any data from the source, in that case you need to edit the transformation source to remove the namespaces from the xPaths of sources.
Regards,
Ajay -
How to add an element with a namespace prefix (Part 2)
Hi all,
I previously asked a question about adding an attribute with a namespace prefix to an element that already exists and that declares the namespace prefix here:
https://forums.oracle.com/thread/2610142
I received an answer that works, but now I am stumped again when I have to add an element where the element name has the namespace prefix.
For example, let's say I already have this element:
<A xmlns="namespace" xmlns:def="myns_namespace"/>
And I want to add this element:
<def:B/>
To produce this:
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B/>
</A>
and NOT this:
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B xmlns:def="myns_namespace"/>
</A>
This does not work:
SELECT
xmlserialize(document
appendChildXML(
xmltype('<A xmlns="namespace" xmlns:def="myns_namespace"/>')
, '/A'
, xmlelement("def:D")
, 'xmlns="namespace" xmlns:def="myns_namespace"'
indent)
FROM dual;
Because of this error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00234: namespace prefix "def" is not declared
Error at line 1
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.
Is there any way to do this without the child element having the duplicate namespace declaration?
My oracle version is:
Oracle Database 11g Release 11.1.0.7.0 - 64bit ProductionHi,
This one's tricky, so tricky that I think it's not possible using Oracle built-in XML DML functions.
Even XQuery Update cannot do it (for now) because, likewise, the prefix is always redeclared at child level.
The only thing I can think of is XSLT (or maybe DOM manipulation) :
SQL> select xmlserialize(document
2 xmltransform(
3 xmltype('<A xmlns="namespace" xmlns:def="myns_namespace"/>')
4 , xmltype(
5 '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 xmlns:def="myns_namespace"
7 xmlns:ns0="namespace">
8 <xsl:template match="ns0:A">
9 <xsl:copy>
10 <xsl:element name="def:B"/>
11 </xsl:copy>
12 </xsl:template>
13 </xsl:stylesheet>')
14 )
15 indent
16 )
17 from dual;
XMLSERIALIZE(DOCUMENTXMLTRANSF
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B/>
</A> -
Hi,
I am trying to call a small java function in XSL but while performing transformation I get following error
"Function not in namespaceError in XPath expression, Function not in namespace"
I am performing following steps:
1. Java class file placed in class path and classpath is set. Java class is a simple file with no main() function. There is only one function called calculate()
2. Defined a namespace in XSL
3. Calling a function from class file in XSL
My XSL looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fib="java:FibonacciNumber"
extension-element-prefixes="fib" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/" >
<xsl:value-of select="fib:calculate(number(.))"/>
</xsl:template>
</xsl:stylesheet>
Can someone please point out what I am missing out here?
Regards,
NitinPlease refer
http://www.devx.com/Java/Article/31675 -
Hi,
I am trying to call a small java function in XSL but while performing transformation I get following error
"Function not in namespaceError in XPath expression, Function not in namespace"
I am performing following steps:
1. Java class file placed in class path and classpath is set. Java class is a simple file with no main() function. There is only one function called calculate()
2. Defined a namespace in XSL
3. Calling a function from class file in XSL
My XSL looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fib="java:FibonacciNumber" extension-element-prefixes="fib" >
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/" >
<xsl:value-of select="fib:calculate(number(.))"/>
</xsl:template>
</xsl:stylesheet>
Can someone please point out what I am missing out here?
Regards,
NitinLooks like you are using the Xalan convention for java protocol in namespaces.
In Oracle XDK you need to use:
xmlns:fib="http://www.oracle.com/XSL/Transform/java/FibonacciNumber"
Assuming your class is in the default package.
If it is in a package you need the fully qualified name:
xmlns:fib="http://www.oracle.com/XSL/Transform/java/com.foo.FibonacciNumber"
See for example http://www.devx.com/Java/Article/31675/0/page/1
or http://download-east.oracle.com/docs/cd/B14099_11/web.1012/b14033/adx04xsj.htm#i1023310
For more discussion on how hard it is to craft portable functions with Oracle,
see Re: EXSLT implementation
Mik -
Handling EMPTY NAMESPACES IN BPEL XSLT
Hello,
I am getting following response in XSLT. I would like to remove xmlns:"" from my response. Any help is greatly appreciated.
<?xml version="1.0" encoding="UTF-8" ?><Envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<ns1:Header>
<ns0:eiContext xmlns:ns0="http://ei.xxxxxx.com/schemas/envelope/v3_0" xmlns="http://ei.xxxxxx.com/schemas/envelope/v3_0">
<ns0:ei>
<ns0:type>request</ns0:type>
<ns0:service>
<ns0:name>pendingTransactionProcessor</ns0:name>
<ns0:version>1.0</ns0:version>
</ns0:service>
<ns0:originator>EIDev</ns0:originator>
<ns0:businessProcessName>default</ns0:businessProcessName>
<ns0:servicerInfo/>
<ns0:requestDateTime>2013-03-21T23:10:47.450Z</ns0:requestDateTime>
<ns0:sequenceNumber>001.001</ns0:sequenceNumber>
<ns0:user>
<ns0:id>EIDev</ns0:id>
<ns0:group>Selfcare</ns0:group>
</ns0:user>
<ns0:transactionReference>20130606PTPTest002</ns0:transactionReference>
<ns0:expirationSeconds>120</ns0:expirationSeconds>
<ns0:additionalParameters>
<ns0:param>
<ns0:name>accountId</ns0:name>
<ns0:value>332602</ns0:value>
</ns0:param>
<ns0:param>
<ns0:name>targetService</ns0:name>
<ns0:value>modifyReceiverPS</ns0:value>
</ns0:param>
<ns0:param>
<ns0:name>targetServiceVersion</ns0:name>
<ns0:value>4.0</ns0:value>
</ns0:param>
</ns0:additionalParameters>
</ns0:ei>
<ns0:context>
<PTPContext xmlns="">
<PTPRequestStatus>ASYNC_PROCESS</PTPRequestStatus>
</PTPContext>
</ns0:context>
</ns0:eiContext>
</ns1:Header>
</Envelope>Hi,
Use below XSLT logic to remove empty namespaces,
<xsl:stylesheet version="1.0" ">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:element name="{name()}" namespace="{namespace-uri()}">
<xsl:copy-of select="@*|namespace::*[name()]"/>
<xsl:apply-templates select="node()"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
-Santosh -
We are using the default clause with xmlnamespaces. However, it does not support the use of a variable, only a string literal.
How do we avoid hardcoding this namespace in the PL/SQL? Typically we would soft-code this so that the namespace is read from a table. As is, changing the namespace requires a change and recompile of code.
for r in (select *
from xmltable(xmlnamespaces (default 'http://schemas.abcdefg.com/servicemarket/resourceavailabilitynotification/20081120'),
'/ResourceAvailabilityNotification/Body/Resources/Resource'
passing p_message
columns isrc varchar2(12) path 'Isrc',
available varchar2(5) path 'Available'
)) loop
end loop;Thanks,
ToddI made some changes, the following xsl removes all the namespaces and one attribute the xsi:schemaLocation.
I added some dummy attributes to the xml to see that only the schemaLocation will be removed. Looks like it works.
SQL> with t as (select xmltype('<?xml version="1.0" encoding="UTF-8"?>
2 <ns1:ResourceAvailabilityNotification
3 xsi:schemaLocation="http://schemas.abcdef.com/resourceavailabilitynotification"
4 xmlns:ns1="http://schemas.abcdef.com/resourceavailabilitynotification"
5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
6 <ns1:Header>
7 <Id iid="a">String</Id>
8 <CallThreadId k="aaaa">String</CallThreadId>
9 </ns1:Header>
10 </ns1:ResourceAvailabilityNotification>') xcol from dual)
11 select xmltransform(xcol
12 ,xmltype('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
13 <xsl:template match="*">
14 <xsl:element name="{local-name()}" namespace="">
15 <xsl:apply-templates select="@* | node()" />
16 </xsl:element>
17 </xsl:template>
18 <xsl:template match="@*">
19 <xsl:if test="name(.)!=''xsi:schemaLocation''">
20 <xsl:attribute name="{local-name()}">
21 <xsl:value-of select="."/>
22 </xsl:attribute>
23 </xsl:if>
24 </xsl:template>
25 </xsl:stylesheet>')) xml
26 from t;
XML
<ResourceAvailabilityNotification>
<Header>
<Id iid="a">String</Id>
<CallThreadId k="aaaa">String</CallThreadId>
</Header>
</ResourceAvailabilityNotification>Ants -
Hi,
I have the following document
<ns4:product xmlns:ns1="www.abc.com" xmlns:ns2="www.def.com" xmlns:ns3="www.ghi.com" xmlns:ns4="www.jkl.com">
<ns4:productline>Widget</ns4:productline>
</ns4:product>
I'm trying to find a SQL function which will enable me to extract the namespace prefix with the value "www.jkl.com". This is so that I can then use the prefix as part of the xpath expression to search for an element value in the document eg. extractvalue('/ns4:product/ns4:productline')
ThanksHi,
This one's tricky, so tricky that I think it's not possible using Oracle built-in XML DML functions.
Even XQuery Update cannot do it (for now) because, likewise, the prefix is always redeclared at child level.
The only thing I can think of is XSLT (or maybe DOM manipulation) :
SQL> select xmlserialize(document
2 xmltransform(
3 xmltype('<A xmlns="namespace" xmlns:def="myns_namespace"/>')
4 , xmltype(
5 '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 xmlns:def="myns_namespace"
7 xmlns:ns0="namespace">
8 <xsl:template match="ns0:A">
9 <xsl:copy>
10 <xsl:element name="def:B"/>
11 </xsl:copy>
12 </xsl:template>
13 </xsl:stylesheet>')
14 )
15 indent
16 )
17 from dual;
XMLSERIALIZE(DOCUMENTXMLTRANSF
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B/>
</A> -
XSLT Mapping: Problem in appending xmlns attribute
Hi
This is my source message
<?xml version="1.0" encoding="UTF-8"?>
<soap-env:Envelope xmlns:soap-env= "http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Body>
<OrderID xmlns="http://dummyvalue">12345</OrderID>
</soap-env:Body>
My XSLT mapping
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<soap-env:Envelope>
<soap-env:Body>
<OrderID>
<xsl:attribute name = "xmlns" >
<xsl:value-of select="@xmlns"/>
</xsl:attribute>
<xsl:text>12345</xsl:text>
</OrderID>
</soap-env:Body>
</soap-env:Envelope>
</xsl:template>
</xsl:stylesheet>
I am getting the error message as
ERROR: Description: The value of the 'name' attribute may not be 'xmlns'.
Please help me how to append xmlns attribute in OrderID element ??Hi,
Use <xsl:element> to create a node in the output and specify the namespace.
<xsl:element
name="name"
namespace="URI"
use-attribute-sets="namelist"> <!-- Content:template --></xsl:element>
Thanks,
Beena. -
How to remove xmlns in node level
Hi Experts!
How to remove xmlns in node level in response xml file. I tried to use AF_Modules/XMLAnonymizerBean, but it did not work.
Can you please help me out on this.
I want to remvoe xmlns tag in LEVICOM
Eg:
- <Addenda>
- <LEVICOM xmlns="">
Thanks,
HariHi Expers!
Please help me out on this. The below xslt mapping working only to remove xmlns prefix in xml file, if parent having only one child. This code is not working if parent having multiple childs.
Eg: <parent>
<phild xmlns="">
test1
</phild>
</parent>
The above example working fine with below xslt mapping to remove xmlns tag.
Second scenarion not working
Eg: <parent>
<child1 xmlns="">
test1
</child1>
<child2 xmlns="">
test2
</child2>
</parent>
The above example is not working.
Here is the code:
You can remove the namespace prefixes using an XSLT mapping if they are causing problems with applications outside of XI.
Try the following code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.arconw.com/XI/XSLT_Library/XmlNamespacePrefixRemoval"
version="1.0">
<xsl:output method = "xml" />
<xsl:template match="/">
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:template>
<xsl:template match="*" mode="remprefix">
<xsl:variable name="newname" select="local-name(.)"/>
<xsl:element name="{$newname}" namespace ="{namespace-uri()}">
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
<xsl:apply-templates select="*" mode="remprefix"/>
</xsl:element>
</xsl:template>
<xsl:template mode="copyall" match="@*|comment()|processing-instruction()|text()">
<xsl:copy>
<xsl:apply-templates mode="copyall" select="@*|comment()|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Thanks,
Hari
Maybe you are looking for
-
Satellite 5100 - Question about dead pixels. Is it really dead pixel problem?
Hi, I've got Satellite 5100-603. There have been some dead pixels on display. I don't know is it really dead pixel problem or not because the black area seems to be behind the screen. When i move left and right sides, the black area moves left and ri
-
How do you change print quality for eprinting?
HP Photosmart 5515 OS installed XP The driver does not give this option. I like to do Fast Draft sometimes.
-
Looking for / adding a html logo to website
Hi there, I'm looking for the html code for a flashing logo (ideally simulating neon) so that I can add it to my iWeb page that I am making for my music. Does anyone know if this is possible and have any advice or ideas on how I could achieve this? I
-
Hi, I wrote an app and jar it in a file. However when the code tries to instantiate objects in another jar file (which is in the classpath) it throws a java.lang.NoClassDefFoundError. Arggh...its frutstrating when it works "unjar". BTW inside the app
-
Re: Satellite L850-0C9 - Cannot use USB3.0 External HDD
Hello! I'm looking for some help from you guys because i cannot use my NEW SEAGATE USB 3.0 EXTERNAL HDD 2TB with my labtop (L850-0C9) my labtop has 2 blue USB port and i guess it is USB 3.0 and i checked it from manual. but when i tried to copy data