Namespace declaration inconsistencies

It has occurred to me that there is an inconsistency in the BPEL input message depending on where it is called from... If I test the BPEL process from the BPEL console using the test-form, the namespace of the input message is included. However, when the same BPEL process is called through another BPEL process (partner link), the namespace declaration is omitted.
This makes testing harder, since my XPath expressions will then either fail when I test from the BPEL Console, or when the process is invoked from another bpel.
The best way to fix it (I think) is to force the calling bpel process to include the namespace declaration when invoking the partner link. Is there a way to accomplish this?
Cheers,
Bastiaan

Bastian
I have come across the same problem.
The BPEL Console is producing an XML message that is not consistent with the defined schema.
Has anyone else seen any other comments relating to this area - has it been raised as a bug?
I have included my message structures below.
BPEL Console Messsage - the namespaces in bold are the ones that are incorrect
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://itv.com/parispublish">
<ns1:ParisPublishProcessRequest xmlns:ns2="http://itv.com/schemas/message/paris">
<ns2:ProgrammeAdviseRq>
<ns2:HeaderRq xmlns:ns3="http://itv.com/schemas/header/paris">
<ns3:RqUID>ABC</ns3:RqUID>
<ns3:Action>Add</ns3:Action>
</ns2:HeaderRq>
<ns2:Programme xmlns:ns4="http://itv.com/schemas/productcatalogue/paris">
<ns4:ProgrammeId>1234</ns4:ProgrammeId>
</ns2:Programme>
</ns2:ProgrammeAdviseRq>
</ns1:ParisPublishProcessRequest>
</soap:Body>
</soap:Envelope>
Partnerlink message - which is correct.
<inputVariable>
     <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
          <soap:Envelope xmlns="http://itv.com/parispublish" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
               <soap:Header/>
               <soap:Body>
                    <ProgrammeAdviseRq xsi:schemaLocation="http://itv.com/schemas/message/paris ../Message.xsd" xmlns="http://itv.com/schemas/message/paris" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                         <HeaderRq xmlns="http://itv.com/schemas/header/paris">
                              <RqUID>564</RqUID>
                              <Action>Add</Action>
                         </HeaderRq>
                         <Programme xsi:schemaLocation="http://itv.com/schemas/productcatalogue/paris ../productcatalogue.xsd" xmlns="http://itv.com/schemas/productcatalogue/paris">
                              <ProgrammeId>G/0002</ProgrammeId>
                                                  </Programme>
                    </ProgrammeAdviseRq>
               </soap:Body>
          </soap:Envelope>
     </part>
</inputVariable>

Similar Messages

  • Namespace declarations

    I have an XML file that declares some namespaces in its root
    element, like this:
    <config-ui xmlns='ocfgui.dtd'
    xmlns:cfg='ocfg.dtd'>
    |
    (innards deleted)
    |
    </config-ui>
    When I run this though the Oracle XMLParser v2.0.0 with
    validation on, I get "Illegal attribute name" errors on the
    namespace declarations. It's true that they're not in my DTD,
    but I didn't think the DTD had to specify xmlns attributes on
    every element that could use them. I thought that as reserved
    attribute names, they were implicitly valid on any element. Can
    someone set me straight on this?
    null

    David, see http://www.jclark.com/xml/xmlns.htm which states that
    the XML Namespaces Recommendation doesn't define additional
    validity distinct from XML 1.0 validity, so the behavior of our
    parsers is correct. There are two ways you can minimize size of
    your document. Either namespace scoping/defaulting, or attribute
    defaulting. See also section 5 of the following:
    http://www.w3.org/TR/1999/REC-xml-names-19990114/
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    David Kulik (guest) wrote:
    : I have an XML file that declares some namespaces in its root
    : element, like this:
    : <config-ui xmlns='ocfgui.dtd'
    : xmlns:cfg='ocfg.dtd'>
    : |
    : (innards deleted)
    : |
    : </config-ui>
    : When I run this though the Oracle XMLParser v2.0.0 with
    : validation on, I get "Illegal attribute name" errors on the
    : namespace declarations. It's true that they're not in my DTD,
    : but I didn't think the DTD had to specify xmlns attributes on
    : every element that could use them. I thought that as reserved
    : attribute names, they were implicitly valid on any element.
    Can
    : someone set me straight on this?
    null

  • Namespace declaration and W3C standart

    Hello,
    W3C has following specs for Namespace declaration in XQuery:
    http://www.w3.org/TR/xquery/#id-namespace-decls
    "[117]      NamespaceDecl      ::=      "declare" "namespace" NCName "=" StringLiteral
    A namespace declaration declares a namespace prefix and associates it with a namespace
    URI, adding the (prefix, URI) pair to the set of in-scope namespaces. The string
    literal used in a namespace declaration must be a valid URI, and may not be a
    zero-length string.[err:XQ0046] The namespace declaration is in scope throughout
    the query in which it is declared, unless it is overridden by a namespace declaration
    attribute in an element constructor.
    The following query illustrates a namespace declaration:
    declare namespace foo = "http://example.org";
    <foo:bar> Lentils </foo:bar> "
    BNF production grammar requires "declare" token to be placed before namespace,
    while
    Liquid Data reports parsing error if the word is there.
    How close Liquid Data XQuery grammar to the W3C standart?
    Also, does "of type" exist in XQuery ?
    Sincerely,
    Benjamin.

    Thank you for quick answer.
    Sorry, my fault - didn't notice that fact.
    Benjamin.
    "Mike Reiche" <mreiche@news_group_only.com> wrote:
    LD 8.1 was released in July 2003 (before the August 2003 spec). It adheres
    to
    http://www.w3.org/TR/2001/WD-xquery-20011220/#id-namespace-decls-and-schemas
    http://e-docs.bea.com/liquiddata/docs81/prodover/concepts.html
    - Mike Reiche
    "Benjamin Shrom" <[email protected]> wrote:
    Hello,
    W3C has following specs for Namespace declaration in XQuery:
    http://www.w3.org/TR/xquery/#id-namespace-decls
    "[117]      NamespaceDecl      ::=      "declare" "namespace" NCName
    "=" StringLiteral
    A namespace declaration declares a namespace prefix and associates it
    with a namespace
    URI, adding the (prefix, URI) pair to the set of in-scope namespaces.
    The string
    literal used in a namespace declaration must be a valid URI, and may
    not be a
    zero-length string.[err:XQ0046] The namespace declaration is in scope
    throughout
    the query in which it is declared, unless it is overridden by a namespace
    declaration
    attribute in an element constructor.
    The following query illustrates a namespace declaration:
    declare namespace foo = "http://example.org";
    <foo:bar> Lentils </foo:bar> "
    BNF production grammar requires "declare" token to be placed beforenamespace,
    while
    Liquid Data reports parsing error if the word is there.
    How close Liquid Data XQuery grammar to the W3C standart?
    Also, does "of type" exist in XQuery ?
    Sincerely,
    Benjamin.

  • Avoid repeating namespace declaration in xml output

    Hi all,
    I'm trying an IDoc -> XML File (specifically UBL-format) scenario, and it is working fine. But the resulting XML contains repeating namespace declarations for each element, instead of a "common" declaration at the root element.
    How can I avoid this, so the message contains the namespace declarations in root node, and only uses the namespace prefix for each element?
    The target format, external definition, is an XSD with several import statements, and all external references have been set up, meaning all referenced XSD's are imported too, and have the "Source"-field set according to the import statement.
    Sample result file (top of file only):
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Invoice xmlns:ns0="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
    <ns2:UBLVersionID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2.0</ns2:UBLVersionID>
    <ns2:CustomizationID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">urn:www.cenbii.eu:transaction:BiiCoreTrdm001:ver1.0:extentionId</ns2:CustomizationID>
    <ns2:ProfileID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">urn:www.cenbii.eu:profile:bii05:ver1.0</ns2:ProfileID>
    <ns2:ID xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">9010045446</ns2:ID>
    <ns2:IssueDate xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">2011-04-19</ns2:IssueDate>
    <ns2:InvoiceTypeCode...
    PI version 7.11.
    Thanks for all help.
    Br,
    Kenneth

    Hi Mon,
    You can use below xslt 1.0 mappings.
    The first one will copy all namespaces (declared) to a newly created root element.
    The seconde one will delete the 'old' root element.
    => The result will look like an xml where the namespacesare moved to the root element.
    First xslt:
    <?xml version='1.0' encoding='utf-8'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8"/>
    <xsl:template match="/">
    <Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ns3="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ns4="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
    <xsl:copy-of select="." />
    </Invoice>
    </xsl:template>
    </xsl:stylesheet>
    Second xslt:
    <?xml version='1.0' encoding='utf-8'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8"/>
    <xsl:template match="@* | node()">
      <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
    </xsl:template>
    <xsl:template match="Invoice" >
      <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    Kind regards,
    Lode

  • RFC Call: Missing namespace declaration

    Dear experts,
    I have a file to RFC scenario. I imported the RFC and create files exactly according to the RFC structure, so I don't use a mapping. When I create a file, it provides the following error in the adapter log:
    <i>Exception caught by adapter framework: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: could not get functionname from XML requst: com.sap.aii.af.rfc.RfcAdapterException: failed to read funtionname from XML document: missing namespace declaration(2)</i>
    What do I need to do to fix this.
    Thanks in advance!

    This is the whole message:
    I created my own interface and mapped it to the RFC:
    This is the message. Now it successfully pass XI and the adapter sais it is delivered.
    BUT nothing is seen in the target system... how is that possible???
    <?xml version="1.0" ?>
    <ns:MT_TO_CREATE xmlns:ns="urn://cchbc/w2/xi/mes/warehousetransfer">
    <LGNUM></LGNUM>
    <TIMEST>20071207094550.0000000</TIMEST>
    <WERKS>4510</WERKS>
    <ZLAST>0</ZLAST>
    <ZSCID>SCANPRD4</ZSCID>
    <I_LTAP>
    <item>
    <EAN11>5449000003096</EAN11>
    <LETYP>E2</LETYP>
    <VSOLM>48.000</VSOLM>
    <LENUM>00345101239500010930</LENUM>
    <VFDAT>2008-12-11T00:00:00</VFDAT>
    <WDATU>2007-12-07</WDATU>
    <ZLINE>830</ZLINE>
    <ZTIME>09:43:32</ZTIME>
    <BRGEW/>
    </item><item>
    <EAN11>2229000058744</EAN11>
    <LETYP>E2</LETYP>
    <VSOLM>48</VSOLM>
    <LENUM>00000000003000002961</LENUM>
    <VFDAT>2008-12-11T00:00:00</VFDAT>
    <WDATU>2007-12-07</WDATU>
    <ZLINE>830</ZLINE>
    <ZTIME>09:44:01</ZTIME>
    <BRGEW/></item><item>
    <EAN11>2229000058744</EAN11>
    <LETYP>E2</LETYP>
    <VSOLM>48.000</VSOLM>
    <LENUM>00000000003000002978</LENUM>
    <VFDAT>2008-12-11T00:00:00</VFDAT>
    <WDATU>2007-12-07</WDATU>
    <ZLINE>830</ZLINE>
    <ZTIME>09:44:32</ZTIME>
    <BRGEW/></item></I_LTAP></ns:MT_TO_CREATE>
    And the output is:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns1:ZWM_TO_CREATE xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
      <LGNUM />
      <TIMEST>20071207094550.0000000</TIMEST>
      <WERKS>4510</WERKS>
      <ZLAST>0</ZLAST>
      <ZSCID>SCANPRD4</ZSCID>
    - <I_LTAP>
    - <item>
      <EAN11>5449000003096</EAN11>
      <LETYP>E2</LETYP>
      <VSOLM>48.000</VSOLM>
      <LENUM>00345101239500010930</LENUM>
      <VFDAT>2008-12-11T00:00:00</VFDAT>
      <WDATU>2007-12-07</WDATU>
      <ZLINE>830</ZLINE>
      <ZTIME>09:43:32</ZTIME>
      <BRGEW />
      </item>
    - <item>
      <EAN11>2229000058744</EAN11>
      <LETYP>E2</LETYP>
      <VSOLM>48</VSOLM>
      <LENUM>00000000003000002961</LENUM>
      <VFDAT>2008-12-11T00:00:00</VFDAT>
      <WDATU>2007-12-07</WDATU>
      <ZLINE>830</ZLINE>
      <ZTIME>09:44:01</ZTIME>
      <BRGEW />
      </item>
    - <item>
      <EAN11>2229000058744</EAN11>
      <LETYP>E2</LETYP>
      <VSOLM>48.000</VSOLM>
      <LENUM>00000000003000002978</LENUM>
      <VFDAT>2008-12-11T00:00:00</VFDAT>
      <WDATU>2007-12-07</WDATU>
      <ZLINE>830</ZLINE>
      <ZTIME>09:44:32</ZTIME>
      <BRGEW />
      </item>
      </I_LTAP>
      </ns1:ZWM_TO_CREATE>

  • How to remove SOAP namespaces declarations in body content?

    Hi!
    I'm calling a WS with WS-Security without problems but when I extract the content the SOAP message's Body(the "business" part), the namespace declarations of the SOAP part (envelope, security, etc.) are present in the root element. However, any of this namespaces is referenced in the message that I extract.
    I'm extracting the message inside the body like this
    XmlObject[] aXml = xml.selectPath(##THE QUERY##);
    return XmlObject.Factory.parse(aXml[0].xmlText(_opts));
    Is there a way of getting rid of these declarations?
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    I've tried changing the XmlOptions (setSaveAggresiveNamespaces, setLoadSubstituteNamespaces, etc.) without success.
    Thanks in advance!

    just use $body/* and you will have what u wanted.

  • Retrieve namespace  declarations from unmarshalled object

    Hi,
         I hope this is a beginner's question:
    Still working on a web service, that uses an EJB for implementation. I'm using types/classes that were derived automatically from a WSDL (top-down/outside-in/what have you), or rather the corresponding schemata. I'm trying to retrieve namespace declarations from the unmarshalled object/element, but  they are not contained in the "otherAttributes" [Map<QName, String>] member field of the respective object. However, I can retrieve any other attribute, qualified and non qualified, as long as the namespace isn't that of xmlns (http://www.w3.org/2000/xmlns/). For example:
    Client:
                MyElement my_element = new MyElement();
                Map<QName, String> atts = my_element.getOtherAttributes();
                QName ns_att = new QName("http://www.w3.org/2000/xmlns/", "a");
                atts.put(ns_att, "http://www.example.com/");
                QName test_att = new QName("test-att");
                atts.put(test_att, "http://www.example2.com");
    Service:
                MyElement my_element = parent.getMyElement(); // ...
                Map<QName, String> atts = my_element.getOtherAttributes();
                for (QName qn :  atts.keySet()) {
                    System.out.println("qn: ["+qn+"] value["+atts.get(qn)+"]");
    This would print:
    qn: [test-att] value[http://www.example2.com]
    What am I missing? How do I get the namespace declaration? Thanks for your help in advance.
    Cheers,
    Felix

    I'll try to explain in a better way ...
    I have a server with 2 different client and each client communicate to the server with a different interface.
    My needs are to recognize from the server, the type of the client that are operating, and to do this I was thinking to recognize the interface used from the client to interact with the server
    An other option is that, from the client, after retrieving the server and it's cast, a can call a method to pass to the server object, the type of the interface actually used.
    But I think this makes a bit of nonsense because When I receive the marshalled object in my opinion doesn't make sense that i have to say the object it's type (the interface used).
    the object is already alive and I think it has to know the interface used to refer it even if is on another VM
    The cast operation doesn't store nothing into the current object instance?
    local code example (I don't know if with JRMI the situation is different because the different JVM)
    Map foo = new HashTable();
    I need a method like
    foo.curretUsedInterface() ... that return "Map"
    instead of
    foo.getClass().getName() that return "HashMap"
    It's possible to obtain this information or I have to try another idea to make the server distinguish the client type?
    thank you very much for your comprehension

  • Unnecessary  Namespace declarations

    Hi,
    When mapping (graphic) to an externally defined XML schema where some elements belong to different namespaces I get namespace declarations on each element in the resulting XML instance even though they refer to the same ns name. The problem is that the XML document, even though valid, is very verbose. Is there a way to get all ns declarations in the root element instead without using XSLT?
    Example output
    <?xml version="1.0" encoding="utf-8" ?>
    <ns1:RootElement xmlns:ns1="http://foo.com">
    <ns2:Element1 xmlns:ns2="http://junk.com" />
    <ns2:Element2 xmlns:ns2="http://junk.com" />
    <ns2:Element3 xmlns:ns2="http://junk.com" />
    </ns1:RootElement>
    I would like to get something like this instead:
    <?xml version="1.0" encoding="utf-8" ?>
    <ns1:RootElement xmlns:ns1="http://foo.com" xmlns:ns2="http://junk.com">
    <ns2:Element1 />
    <ns2:Element2 />
    <ns2:Element3 />
    </ns1:RootElement>
    Kind regards Johan

    Hi,
    I was probably not clear enough in my question.
    My Scenario is CRM -> Xi -> External system.
    The inbound interface to the external system is a predefined XML Schema where not all components/elements belong to the same namespace.
    When executing a mapping, created with the graphical mapping tool in Xi, the resulting XML document/Instance is valid but very verbose since XI put namespace declarations in every element over and over again instead of just putting them once in the root element.
    I don't think this has anything to do with the XSD, but rather with the mapping program.
    The result is that the receiving system takes a performance hit. I would like to find a way to force XI to just declare the same ns once in the root element instead of over and over again?
    kind regards Johan

  • Duplicate namespace declarations when writing a file with JCA file adapter

    I am using JCA File adapter to write a an XML file. The composite contains a mediator which received and transforms an XML to desired format and then calls a JCA file adapter to write the file.
    The problem that I am having is that the written file has declaration of namespaces repeated with repeating elements instead of a single declaration at root. For ex.
    instead of
    <ns0:Root xmlns:ns0="namespace0"  xmlns:ns1="namespace1" xmlns:ns2="namespace2">
    <ns0:RepeatingChild>
    <ns1:Element1>value1</ns1:Element1>
    <ns2:Element2>value2</ns2:Element2>
    </ns0:RepeatingChild>
    <ns0:RepeatingChild>
    <ns1:Element1>value3</ns1:Element1>
    <ns2:Element2>value4</ns2:Element2>
    </ns0:RepeatingChild>
    </ns0:Root>What I see in the file is:
    <ns0:Root xmlns:ns0="namespace0"  xmlns:ns1="namespace1" xmlns:ns2="namespace2">
    <ns0:RepeatingChild>
    <ns1:Element1 xmlns:ns1="namespace1" xmlns:"namespace1">value1</ns1:Element1>
    <ns2:Element2 xmlns:ns2="namespace2" xmlns:"namespace2">>value2</ns2:Element2>
    </ns0:RepeatingChild>
    <ns0:RepeatingChild>
    <ns1:Element1 xmlns:ns1="namespace1" xmlns:"namespace1">>value3</ns1:Element1>
    <ns2:Element2 xmlns:ns2="namespace2" xmlns:"namespace2">>value4</ns2:Element2>
    </ns0:RepeatingChild>
    </ns0:Root>So basically all the elements which are in different namespace than root element have a namespace declaration repeated even though the namespace identifier is declared at the root elment level.
    Although, the XML is still valid, but this is unnecessarily increasing the filesizes 3-4 times. Is there a way I can write the XML file without duplicate declarations of namespaces?
    I am using SOA Suite 11.1.1.4
    The file adapter has the schema set as above XML.
    I tried the transformation in mediator using XSL and also tried using assign [source(input to mediator) and target(output of mediator, input of file adapter) XMLs are exactly same].
    but no success.

    I used automapper of JDeveloper to generate the schema. The source and target schema are exactly same.
    I was trying to figure it out and I observed that if the namespaces in question are listed in exclude-result-prefixes list in xsl, then while testing the XSL in jDeveloper duplicate namespaces occur in the target and if I remove the namespace identifiers from the exclude-result-prefixes list then in jDeveloper testing the target correctly has only a single namespace declaration at the root node.
    But, when I deployed the same to server and tested there, again the same problem.

  • Namespace declaration using DOM

    Hi,
    I am using DOM to create an XML document. How do I declare namespace?
    I want to know which API is used to create namespace declaration in an XML document.
    I want my final XML document to be
    <RootElement xmlns:c="http://pradeep.somesite.com">
    <name>pradeep</name>
    <RootElement>
    My problem is how to put the xml ns declaraton in RootElement.
    Some one plz help;
    thanks in adv.

    xmlns is like any other attribute.
    Try something like:
    NamedNodeMap attributes = rootElement.getAttributes();
    Attr namespace = myDoc.createAttribute("xmlns");
    namespace.setValue("........");
    attributes.setNamedItem(namespace);

  • CFFEED & Namespace Declaration

    I would appreciate some help with generating rss feed for Google Merchant.  I am trying to use cffeed to generate the xml file which I am good with.  The issue is formatting it to google's specifications and their namespace declaration (<g:price></g:rpice>)  how to set a xml structure to include g:  in front of the names?
    Here is a sample of googe xml structure:
    <?xml version="1.0"?>
    <rss version="2.0"
    xmlns:g="http://base.google.com/ns/1.0">
    <channel>
    <title>The name of your data feed</title>
    <link>http://www.example.com</link>
    <description>A description of your content</description>
    <item>
    <title>Red wool sweater</title>
    <link> http://www.example.com/item1-info-page.html</link>
    <description>Comfortable and soft, this sweater will keep you warm on those cold winter nights.</description>
    <g:image_link>http://www.example.com/image1.jpg</g:image_link>
    <g:price>25</g:price>
    <g:condition>new</g:condition>
    <g:id>1a</g:id></item>
    </channel>
    </rss>

    I had a google around, and as far as I can tell it cannot be done with <cffeed> (*).  Just use <cfxml> instead, I reckon.
    And maybe raise an issue with Adobe: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html.  If you do so, and post the bug ref back here, I'll vote for it too :-)
    Adam
    (*) http://www.coldfusionjedi.com/index.cfm/2008/4/23/Ask-a-Jedi-Handling-RSS-feeds-with-custo m-data.  Ray's pretty clued up about these things, so I'd take his word for it.

  • Add a root node and namespace declaration

    According to the requirement,I have a large appended .txt file.
    This .txt file is created by appending various xml files (without the namespace and root node).
    I need to add a root node and namespace declaration to the large appended .txt file so that it can be read as .xml.
    Please provide the pointers for the same.
    Thanks & Regards,
    Rashi

    My appended file looks like following.
    <input>
       <Store>
          <StoreHeader>
             <StoreNbr>56</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    <input>
       <Store>
          <StoreHeader>
             <StoreNbr>123</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>B</Item>
                <ItemPrice>8</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    Now according to the requirement, I need to add namespace and root node and make it like follows:
    <ns0:output xmlns:ns0="http://xxx">
       <input>
       <Store>
          <StoreHeader>
             <StoreNbr>56</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    <input>
       <Store>
          <StoreHeader>
             <StoreNbr>123</StoreNbr>
             <StoreType>Retail</StoreType>
             <StoreSite>2004</StoreSite>
          </StoreHeader>
          <Transactions>
             <Transaction>
                <Item>A</Item>
                <ItemPrice>4</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>B</Item>
                <ItemPrice>8</ItemPrice>
             </Transaction>
             <Transaction>
                <Item>C</Item>
                <ItemPrice>56</ItemPrice>
             </Transaction>
          </Transactions>
       </Store>
    </input>
    </ns0:output>

  • Oracle9i XMLType and namespace declaration

    Hi Folks,
    I am using the new XMLType for storing XML data and when I want to insert a XML document that contains a namespace declaration
    using sys.XMLType.createXML('<lom xmlns="http://www.imsglobal.org/xsd/imsmd_rootv1p2p1"...>...</lom>') function, nothing is inserted into the field and no error message is shown. If I remove the namespace declaration like: sys.XMLType.createXML('<lom>...</lom>') then it works.
    I am wondering if there is a problem with the XML Parser or I should do something that I don't. I have read most of the online documents in this regard but couldn't find any answer.
    Your help is really appreciated.
    Bahram Jalili

    I ran into the same (almost) problem a few weeks ago and posted a question to this forum - no response... sigh. Seems like a pretty obvious bug.

  • Stripping namespace declaration (but keep prefix)

    Hi,
    I have the following function that strips namespace from an element:
    declare function local:strip-namespace($e as element()) as element() {
       element {QName((),local-name($e))} {
        for $child in $e/(@*,node())
            return if ($child instance of element())
                then local:strip-namespace($child)
                else $child
    };So, when I call this function:
    return local:strip-namespace(<dc:creator rdf:resource="http://myce.org/creator/{$h}"/>)it removes the namespace declaration (the initial problem) but it also removes the prefix <b>dc</b>. I need to keep that prefix. How do I achieve this?
    Thanks for any tips in advance.

    Hi Mon,
    You can use below xslt 1.0 mappings.
    The first one will copy all namespaces (declared) to a newly created root element.
    The seconde one will delete the 'old' root element.
    => The result will look like an xml where the namespacesare moved to the root element.
    First xslt:
    <?xml version='1.0' encoding='utf-8'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8"/>
    <xsl:template match="/">
    <Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ns3="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ns4="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
    <xsl:copy-of select="." />
    </Invoice>
    </xsl:template>
    </xsl:stylesheet>
    Second xslt:
    <?xml version='1.0' encoding='utf-8'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" encoding="UTF-8"/>
    <xsl:template match="@* | node()">
      <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
    </xsl:template>
    <xsl:template match="Invoice" >
      <xsl:apply-templates/>
    </xsl:template>
    </xsl:stylesheet>
    Kind regards,
    Lode

  • Inclusion of unused namespace declarations in marshalled XML

    Hello.
    I have noticed that by default any XML marshaled from an object contains namespace declarations related to every package specified when instantiating the JAXBContext even though they are not used in the instance being marshalled.
    Is there any way to avoid this during the marshalling as opposed to via some sort of post processing (e.g. XSLT transform).
    Example source below:
    package test;
    import javax.xml.bind.*;
    import java.io.*;
    import test.sample1.*;
    import test.sample2.*;
    public class Converter {
         public static void main(String[] args) {
              try {
                   String sample1 = "<Message1 xmlns=\"http://www.example.org/sample1\">" +
                                             "<tns:Field xmlns:tns=\"http://www.someother.org\">value</tns:Field>" +
                                        "</Message1>";
                   String sample2 = "<Message2 xmlns=\"http://www.example.org/sample2\">" +
                                            "<Field1>value1</Field1>" +
                                            "<Field2>value2</Field2>" +
                                        "</Message2>";
                   JAXBContext ctx = JAXBContext.newInstance("test.sample1:test.sample2");
                   Unmarshaller um = ctx.createUnmarshaller();
                   Marshaller m = ctx.createMarshaller();
                   StringWriter sw1 = new StringWriter();                
                   Message1 msg = (Message1)um.unmarshal(new StringReader(sample1));
                   m.marshal(msg, sw1);               
                   System.out.println("Marshalled sample1: \n"+sw1.toString());
                   StringWriter sw2 = new StringWriter();                
                   Message2 msg2 = (Message2)um.unmarshal(new StringReader(sample2));
                   m.marshal(msg2, sw2);               
                   System.out.println("Marshalled sample2: \n"+sw2.toString());
              } catch (JAXBException e) {
                   e.printStackTrace();
    }Produces output:-
    Marshalled sample1:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Message1 xmlns:ns2="http://www.example.org/sample2" xmlns="http://www.example.org/sample1"><tns:Field xmlns:tns="http://www.someother.org">value</tns:Field></Message1>
    Marshalled sample2:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:Message2 xmlns:ns2="http://www.example.org/sample2" xmlns="http://www.example.org/sample1"><ns2:Field1>value1</ns2:Field1><ns2:Field2>value2</ns2:Field2></ns2:Message2>

    Thanks for the quick response. I really appreciate it.
    Yes, as you say, there is no real problem as such but part of my app lets the user see the RAW message XMLs and this could confuse them and would be tidier to remove but I can also see why it is easier from the Marshaller perspective not to have to back track to remove unused declarations.
    Also, I'm a little concerned about the increased size of the XML produced. One of my webservices does handle quite a few different types and our Oracle namespace URLs are all pretty long!
    Like I say, I can see a way to get rid of them after the fact but wondered if there was a more elegant/performant way.

Maybe you are looking for