Unable to modify a XML node which is a SimpleType using a Typed XML field.

Hello,
I have an XSD schema that uses SimpleTypes.  When I attempt to modify a node in an Schema typed XML field, which has a schema using simpletypes, I receive the error:  XQuery [modify()]: The value is of type "xs:string", which is not a
subtype of the expected type "<anonymous>"
To reproduce the problem use the following information:
SCHEMA:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ns1="http://testschema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="http://testschema" elementFormDefault="qualified" attributeFormDefault="unqualified" vc:minVersion="1.1">
<xs:element name="Test">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="SAPCode">
<xs:annotation>
<xs:documentation>Customer Number for Delivery Organization</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="OrganizationName">
<xs:annotation>
<xs:documentation>Name of Organization</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="AttentionTo" minOccurs="0">
<xs:annotation>
<xs:documentation>Attention to Recepient for the delivery</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150" fixed="false"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Address1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Address2" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Address3" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="City">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="StateProvince">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="PostalCode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Country">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Phone" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="EmailAddress" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="200"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The T-SQL That produces the error:
DECLARE
@vx_Test xml (CONTENT [dbo].[Test]),
@vs_ShipToAttentionTo NVARCHAR(50)
SET
@vx_Test = N'<ns0:Test xmlns:ns0="http://testschema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:SAPCode>1234567890</ns0:SAPCode>
<ns0:OrganizationName>Test Org</ns0:OrganizationName>
<ns0:AttentionTo>Test Person</ns0:AttentionTo>
<ns0:Address1>123 Main Street</ns0:Address1>
<ns0:City>Test City</ns0:City>
<ns0:StateProvince>IL</ns0:StateProvince>
<ns0:PostalCode>12345</ns0:PostalCode>
<ns0:Country>US</ns0:Country>
</ns0:Test>'
SET
@vs_ShipToAttentionTo = 'New Attention To'
SET @vx_Test.modify('declare namespace ns0="http://testschema";
replace value of (/ns0:Test[1]/ns0:AttentionTo) with sql:variable("@vs_ShipToAttentionTo")');
-- This would be how I would reference it if I was modifiying the XML in a typed XML column in a table.
WITH XMLNAMESPACES('http://testschema' AS ns0)
UPDATE TestItems
SET TestXML.modify('replace value of (/ns0:Test[1]/ns0:AttentionTo) with sql:variable("@vs_ShipToAttentionTo")')
SELECT @vx_Test
How can I make this work.  In this example I am using a typed XML variable, but I really want to do this in a table update.
Thanks,
Kent

Try the change below.  What I did was to create a named simple type for the AttentionTo node.  Here is my understanding (based on this working).  Because you have a simpleType the node cannot accept just any string, it has to be a string of
the type in the simpleType.  That simpleType has no name (thus anonymous). 
What I did was to create a named simpleType and used that simpleType as the type for the AttentionTo element.  Then in my XQuery, I cast the value to the name of that type (AttentionToType in my example).
CREATE xml schema collection Test as '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:ns1="http://testschema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="http://testschema" elementFormDefault="qualified" attributeFormDefault="unqualified" vc:minVersion="1.1">
<xs:element name="Test">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="SAPCode">
<xs:annotation>
<xs:documentation>Customer Number for Delivery Organization</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="10"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="OrganizationName">
<xs:annotation>
<xs:documentation>Name of Organization</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="AttentionTo" minOccurs="0" type="ns1:AttentionToType">
<xs:annotation>
<xs:documentation>Attention to Recepient for the delivery</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Address1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Address2" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Address3" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="150"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="City">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="StateProvince">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="PostalCode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Country">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="2"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Phone" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="EmailAddress" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="200"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="AttentionToType">
<xs:restriction base="xs:string">
<xs:maxLength value="150" fixed="false"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>';
go
DECLARE
@vx_Test xml (CONTENT dbo.Test),
@vs_ShipToAttentionTo nvarchar(50)
SET
@vx_Test = N'<ns0:Test xmlns:ns0="http://testschema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns0:SAPCode>1234567890</ns0:SAPCode>
<ns0:OrganizationName>Test Org</ns0:OrganizationName>
<ns0:AttentionTo>Test Person</ns0:AttentionTo>
<ns0:Address1>123 Main Street</ns0:Address1>
<ns0:City>Test City</ns0:City>
<ns0:StateProvince>IL</ns0:StateProvince>
<ns0:PostalCode>12345</ns0:PostalCode>
<ns0:Country>US</ns0:Country>
</ns0:Test>'
SET
@vs_ShipToAttentionTo = 'New Attention To'
SET @vx_Test.modify('declare namespace ns0="http://testschema";
replace value of (/ns0:Test[1]/ns0:AttentionTo) with sql:variable("@vs_ShipToAttentionTo") cast as ns0:AttentionToType?');
-- This would be how I would reference it if I was modifiying the XML in a typed XML column in a table.
WITH XMLNAMESPACES('http://testschema' AS ns0)
UPDATE TestItems
SET TestXML.modify('replace value of (/ns0:Test[1]/ns0:AttentionTo)
with sql:variable("@vs_ShipToAttentionTo")')
SELECT @vx_Test
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

Similar Messages

  • Xml nodes which are not meet the schema validation

    Hi All,
    Is there way to keep xml nodes which are not meet the schema validation ,so that i can send those failed records back to the Source Target.
    I thought to implement to adding validate in the ForEach loop.Any hints

    In Windows you hold down the Ctrl key while clicking on the nodes you want to select. Don't know the equivalent in other environments.

  • How to use xml forms which are built by using xml forms builder?

    Hi Experts,
    please explain How to use xml forms which are built by using xml forms builder in Web page composer?
    Thanks,
    Anil.

    hi buddy u can try the following page:
    http://help.sap.com/saphelp_nw70/helpdata/en/8f/fe743c74fa6449e10000000a11402f/frameset.htm

  • XML Schema Collection (SQL Server 2012): How to create an XML Schema Collection that can be used to Validate a field name (column title) of an existing dbo Table of a Database in SSMS2012?

    Hi all,
    I used the following code to create a new Database (ScottChangDB) and a new Table (marvel) in my SQL Server 2012 Management Studio (SSMS2012) successfully:
    -- ScottChangDB.sql saved in C://Documents/SQL Server XQuery_MacLochlainns Weblog_code
    -- 14 April 2015 09:15 AM
    USE master
    IF EXISTS
    (SELECT 1
    FROM sys.databases
    WHERE name = 'ScottChangDB')
    DROP DATABASE ScottChangDB
    GO
    CREATE DATABASE ScottChangDB
    GO
    USE ScottChangDB
    CREATE TABLE [dbo].[marvel] (
    [avenger_name] [char] (30) NULL, [ID] INT NULL)
    INSERT INTO marvel
    (avenger_name,ID)
    VALUES
    ('Hulk', 1),
    ('Iron Man', 2),
    ('Black Widow', 3),
    ('Thor', 4),
    ('Captain America', 5),
    ('Hawkeye', 6),
    ('Winter Soldier', 7),
    ('Iron Patriot', 8);
    SELECT avenger_name FROM marvel ORDER BY ID For XML PATH('')
    DECLARE @x XML
    SELECT @x=(SELECT avenger_name FROM marvel ORDER BY ID FOR XML PATH('Marvel'))--,ROOT('root'))
    SELECT
    person.value('Marvel[4]', 'varchar(100)') AS NAME
    FROM @x.nodes('.') AS Tbl(person)
    ORDER BY NAME DESC
    --Or if you want the completed element
    SELECT @x.query('/Marvel[4]/avenger_name')
    DROP TABLE [marvel]
    Now I am trying to create my first XML Schema Collection to do the Validation on the Field Name (Column Title) of the "marvel" Table. I have studied Chapter 4 XML SCHEMA COLLECTIONS of the book "Pro SQL Server 2008 XML" written by
    Michael Coles (published by Apress) and some beginning pages of XQuery Language Reference, SQL Server 2012 Books ONline (published by Microsoft). I mimicked  Coles' Listing 04-05 and I wanted to execute the following first-drafted sql in
    my SSMS2012:
    -- Reference [Scott Chang modified Listing04-05.sql of Pro SQL Server 2008 XML by Michael Coles (Apress)]
    -- [shcColes04-05.sql saved in C:\\Documents\XML_SQL_Server2008_code_Coles_Apress]
    -- [executed: 2 April 2015 15:04 PM]
    -- shcXMLschemaTableValidate1.sql in ScottChangDB of SQL Server 2012 Management Studio (SSMS2012)
    -- saved in C:\Documents\XQuery-SQLServer2012
    tried to run: 15 April 2015 ??? AM
    USE ScottChangDB;
    GO
    CREATE XML SCHEMA COLLECTION dbo. ComplexTestSchemaCollection_all
    AS
    N'<?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="marvel">
    <xsd:complexType>
    <xsd:all>
    <xsd:element name="avenger_name" />
    <xsd:element name="ID" />
    </xsd:all>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>';
    GO
    DECLARE @x XML (dbo. ComplexTestSchemaCollection_all);
    SET @x = N'<?xml version="1.0"?>
    <marvel>
    <avenger_name>Thor</name>
    <ID>4</ID>
    </marvel>';
    SELECT @x;
    GO
    DROP XML SCHEMA COLLECTION dbo.ComplexTestSchemaCollection_all;
    GO
    I feel that drafted sql is very shaky and it needs the SQL Server XML experts to modify to make it work for me. Please kindly help, exam the coding of my shcXMLTableValidate1.sql and modify it to work.
    Thanks in advance,
    Scott Chang

    Hi Scott,
    2) Yes, FOR XML PATH clause converts relational data to XML format with a specific structure for the "marvel" Table. Regarding validate all the avenger_names, please see below
    sample.
    DECLARE @x XML
    SELECT @x=(SELECT ID ,avenger_name FROM marvel FOR XML PATH('Marvel'))
    SELECT @x
    SELECT
    n.value('avenger_name[1]','VARCHAR(99)') avenger_name,
    n.value('ID[1]','INT') ID
    FROM @x.nodes('//Marvel') Tab(n)
    WHERE n.value('ID[1]','INT') = 1 -- specify the ID here
    --FOR XML PATH('Marvel')  --uncommented this line if you want the result as element type
    3)i.check the xml schema content
    --find xml schema collection
    SELECT ss.name,xsc.name collection_name FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
    select * from sys.schemas
    --check the schema content,use the name,collection_name from the above query
    SELECT xml_schema_namespace(N'name',N'collection_name')
    3)ii. View can be viewed as virtual table. Use a view to list the XML schema content.
    CREATE VIEW XSDContentView
    AS
    SELECT ss.name,xsc.name collection_name,cat.content
    FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
    CROSS APPLY(
    SELECT xml_schema_namespace(ss.name,xsc.name) AS content
    ) AS cat
    WHERE xsc.name<>'sys'
    GO
    SELECT * FROM XSDContentView
    By the way, it would be appreciated if you can spread your questions into posts. For any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Which iView should be used for displaying XML forms?

    Hi All,
      I have created 3 xml forms.
       1.Edit form
       2.RenderList form
       3.Show form
    So How do I embedd them into iViews?
    Thanks in advance,
    Jasmine.

    HI Jasmine,
    I am not sure if this will help u but u can try this :
    Go to :-
    System Administration -> System Configuration -> Knowledge Management (This is on the left hand side pane) -> Content Management -> Form Based Publishing -> Forms Availability.
    Here in the list of all the Forms that u will see,double click on the form App_All_Public(its a hypelink).
    This will open up the Form details below the list.
    Click on the Edit Button.
    In the textBox for "Forms to Include", enter the project name of the form that u created in XML Form Builder.
    Click on SAVE button to save ur change.
    Now go to ur page and check the links.
    It should show u only the link of the form u want to include for ur user.
    Regards
    Saurabh

  • Copy an xml node

    <TestCase>
    <AuthorizePaymentRq>
    <amount>3.1415926535897932384626433832795</amount>
    <method>Debit</method>
    <parameters>
    <PaymentParameter>
    <Name>String</Name>
    <Value>String</Value>
    </PaymentParameter>
    </parameters>
    </AuthorizePaymentRq>
    <LOB>PL</LOB>
    <ReferenceNumber>234234553</ReferenceNumber>
    <Applicantid>886</Applicantid>
    </TestCase>
    this is my xml file. i need to parse it and i used dom do it.
    i need to copy a node of this xml and put it in to string.
    for example my target will be like this
    String p= "<AuthorizePaymentRq>
    <amount>3.1415926535897932384626433832795</amount><method>Debit</method><parameters> <PaymentParameter><Name>String</Name> <Value>String</Value> </PaymentParameter></parameters>
    </AuthorizePaymentRq>".
    please give me a quick reply ASAP please..

    i am posting this question again for help.
    my request to a service will go like this
    String response = proxy.doAuthorizePayment(lob,RefNumber,appid,XMLInput as a string);
    XMLInput should be a string in xml format which i have to copy from the xml that i gave. please solve this..
    NodeList LOB = doc.getElementsByTagName("LOB");
              NodeList ReferenceNumber = doc.getElementsByTagName("ReferenceNumber");
              NodeList Applicantid = doc.getElementsByTagName("Applicantid");
              Node node;
                   node = LOB.item(0);
                   String lob=node.getChildNodes().item(0).getNodeValue();
         System.out.println(lob+"LOB");
         node=ReferenceNumber.item(0);
              String RefNumber=node.getChildNodes().item(0).getNodeValue();
              System.out.println(RefNumber+"RefNumbe Here");
              node=Applicantid.item(0);
              String appid=node.getChildNodes().item(0).getNodeValue();
                             System.out.println(appid+"Applicantid Here");

  • Xml nodes appearing in spreadsheet

    Hi all,
    I have another question so thought I'd better start a new thread.
    If I have a number of .xml files containing the form data from a Livecycle designer form, I've found that I can merge them all into an excel spreadsheet. When I open up the spreadsheet, I noticed that the data in the first row looks like the following:
    form1[0].Table2[1].Row2[0].firstname[0]
    I named this field "firstname" in the bindings panel and I thought that this would be the content that would appear in that cell within Excel, but it's adding in all those xml nodes which confuses things a lot.
    Is there a way to avoid this?
    Appreciate any further assistance.

    It doesn't have anything to do with Assignment files (the ICMA format).  I said earlier that you'd see that file if you renamed the stories in the Assignments *panel.* (An unfortunate name for the panel. They should call it the InCopy Workflow panel!)
    But you're right, on closer inspection, renaming the files in the panel doesn't create the StoryList.xml file (I coulda sworn it *used to*) but not in 5.5.
    However as I said earlier, you do get that XML file when you reorder the stories *in the Story or Galley view in InCopy.* (not the Assignment panel) You can drag and drop the story bars in those views so they flow logically (title, byline, body, etc.) there.
    AM

  • Edit XML node using actionscript?

    How would I go about editing an XML node from within
    actionscript?
    I load the XML from a file, and before I pass it to an
    HTTPService I would like to set the field DateTime. The XML file
    that I am using can be seen here:
    XML Document
    When I try doing something like
    myXML.fiAPI.fiHeader.Service.DateTime="time here", it creates a new
    fiAPI node with all new children. However, I wish to edit the
    current DateTime field without creating a new one.
    All help is appreciated.

    Thanks to both of you.
    ctzn99: I tried that as well, after realizing my mistake.
    However, it still does not work. I'm certain I have the path right,
    but nothing is set (or in other cases, returned). Even when I use
    myXML.fiHeader..., It creates a new fiHeader node and the
    corresponding nodes underneath it.
    ntsiii: That's a very complex example, like you said...
    almost overkill for my problem?
    Thanks though!

  • Adobe Flex 3, unable to check existing XML nodes

    I am getting an XML data from server(Pls refer xmlData value). I need to: i. Create another XML with non-duplicates Folders ii. Create another XML with final count on monthly basis.
    I am unable to do this with below code and getting duplicate records.
    private var xmlData:XML = new XML("<root><SUMMARY_RECORD><FOLDER>Folder1</FOLDER><COUNT>100</COUNT><MONTH>Feb</MONTH><QUARTER>Q1</QUARTER><YEAR>2014</YEAR></SUMMARY_RECORD><SUMMARY_RECORD><FOLDER>Folder1</FOLDER><COUNT>100</COUNT><MONTH>Feb</MONTH><QUARTER>Q1</QUARTER><YEAR>2014</YEAR></SUMMARY_RECORD></root>");
        var folderDataXML:XML = new XML("<root></root>");
        var folderDGDataXML:XML = new XML("<root></root>");
        private function loaded():void{
            var item:XML;
            folderDGDataXML.appendChild(new XML("<FOLDER_NAME><Name>ALL</Name></FOLDER_NAME>"));
            for each (item in xmlData.SUMMARY_RECORD){
                if (folderDGDataXML.FOLDER_NAME.(Name==item.FOLDER).toString() == ""){
                    folderDGDataXML.appendChild(new XML("<FOLDER_NAME><Name>"+item.FOLDER+"</Name></FOLDER_NAME>"));
                if (folderDataXML.SUMMARY_RECORD.(Name==item.MONTH).toXMLString() == ""){
                    folderDataXML.appendChild(new XML("<SUMMARY_RECORD><Name>"+item.MONTH+"</Name><COUNT>"+item.COUNT+"</COUNT></SUMMARY_RECORD>"));
                }else{
                    var count:int = Number(folderDataXML.SUMMARY_RECORD.(Name==item.MONTH).COUNT) + Number(item.COUNT);
                    folderDataXML.SUMMARY_RECORD.(Name==item.MONTH).COUNT = count;
    Final output:
    folderDGDataXML:   
    <root>
      <FOLDER_NAME>
        <Name>ALL</Name>
      </FOLDER_NAME>
      <FOLDER_NAME>
        <Name>Folder1</Name>
      </FOLDER_NAME>
      <FOLDER_NAME>
        <Name>Folder1</Name>
      </FOLDER_NAME>
    </root>
    folderDataXML: 
    <root>
      <SUMMARY_RECORD>
        <Name>Feb</Name>
        <COUNT>100</COUNT>
      </SUMMARY_RECORD>
      <SUMMARY_RECORD>
        <Name>Feb</Name>
        <COUNT>100</COUNT>
      </SUMMARY_RECORD>
    </root>
    Can you please help me where I am doing wrong? After getting correct XML, I need to populate datagrid & column chart.
    Thanks in advance for the help.
    Regards
    Pavan

    Most loops that eliminate duplicates keep a list/map of the data that has already been processed and compares the loop value against that.
    In ActionScript, it is more efficient to use a map which is usually a plain object.
    var alreadySeenFolders:Map = {};
    In the loop you compare:
        var folderName:String = item.FOLDER.toString();
        if (alreadySeenFolders[folderName] == 1)
            continue; // was already in map
        alreadySeenFolders[folderName] = 1; // store it in map

  • XMLStreamException: Unable to write XML string which starts with the illegal XML char 0x0000

    Hi,
    I am trying to run a WebLogic 8.1 Workshop webservice using Tuxedo Controls. I
    am running in to an XML error:
    <faultcode>JWSError</faultcode>
    <faultstring>com.bea.xml.marshal.XmlEncodingException: Error writing XML stream:
    com.bea.xml.pure.XMLStreamException: Unable to write XML string which starts with
    the illegal XML char 0x0000</faultstring>
    <detail>
    If i look into the application server log file, It says:
    <FML32Deserializer::deserializeInteger>
    ####<Dec 19, 2003 1:25:00 PM CST> <Debug> <WLW> <centurytelweb> <cgServer> <ExecuteThread:
    '11' for queue: 'weblogic.kernel.Default'> <<anonymous>> <BEA1-0237CF026485B78A2335>
    <000000> <Exception deserializing field BUFFERSIZE, exception: weblogic.jws.control.ControlException:
    Error getting field BUFFERSIZE as a Integer, exception: 4 (FNOTPRES)>
    ####<Dec 19, 2003 1:25:00 PM CST> <Debug> <WLW> <centurytelweb> <cgServer> <ExecuteThread:
    '11' for queue: 'weblogic.kernel.Default'> <<anonymous>> <BEA1-0237CF026485B78A2335>
    <000000> <FML32Deserializer::deserializeField - Name=ROWID, type=class java.lang.String>
    But these fields are in the field table class file generated using java weblogic.wtc.jatmi.mkfldclass32

    I am pasting the response i get while i try to run this web service using WebLogic
    Workshop.
    Anyones help would be much appreciated.
    Thanks,
    Deepak
    Service Response
    Submitted at Friday, December 19, 2003 1:25:00 PM CST
    <error>
    <faultcode>JWSError</faultcode>
    <faultstring>com.bea.xml.marshal.XmlEncodingException: Error writing XML stream:
    com.bea.xml.pure.XMLStreamException: Unable to write XML string which starts with
    the illegal XML char 0x0000</faultstring>
    <detail>
    com.bea.wlw.runtime.core.request.ResponseValidationException: com.bea.xml.marshal.XmlEncodingException:
    Error writing XML stream: com.bea.xml.pure.XMLStreamException: Unable to write
    XML string which starts with the illegal XML char 0x0000
    at com.bea.wlw.runtime.jws.request.MimeXmlResponse.setReturnValue(MimeXmlResponse.java:35)
    at com.bea.wlw.runtime.core.bean.BaseDispatcherBean.runAsInvoke(BaseDispatcherBean.java:242)
    at com.bea.wlw.runtime.core.bean.BaseDispatcherBean.invoke(BaseDispatcherBean.java:54)
    at com.bea.wlw.runtime.core.bean.SyncDispatcherBean.invoke(SyncDispatcherBean.java:159)
    at com.bea.wlw.runtime.core.bean.SyncDispatcher_k1mrl8_EOImpl.invoke(SyncDispatcher_k1mrl8_EOImpl.java:100)
    at com.bea.wlw.runtime.core.dispatcher.Dispatcher.remoteDispatch(Dispatcher.java:134)
    at com.bea.wlw.runtime.core.dispatcher.Dispatcher.dispatch(Dispatcher.java:46)
    at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.exploreExec(HttpServerHelper.java:253)
    at com.bea.wlw.runtime.core.dispatcher.HttpServerHelper.executeGetRequest(HttpServerHelper.java:570)
    at com.bea.wlw.runtime.core.dispatcher.HttpServer.doGet(HttpServer.java:81)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6316)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Caused by: com.bea.xml.marshal.XmlEncodingException: Error writing XML stream:
    com.bea.xml.pure.XMLStreamException: Unable to write XML string which starts with
    the illegal XML char 0x0000
    at com.bea.xml.marshal.MarshalContext.error(MarshalContext.java:140)
    at com.bea.xml.marshal.MarshalContext.writeCharacterData(MarshalContext.java:178)
    at com.bea.xml.marshal.AtomicValueMPlan.marshal(AtomicValueMPlan.java:79)
    at com.bea.xml.marshal.MarshalContext.writeElementObjectOrHref(MarshalContext.java:426)
    at com.bea.xml.marshal.BaseMPlan.writeValueUsingStrategy(BaseMPlan.java:307)
    at com.bea.xml.marshal.BaseMPlan.marshal(BaseMPlan.java:349)
    at com.bea.xml.marshal.MarshalContext.writeElementObjectOrHref(MarshalContext.java:426)
    at com.bea.xml.marshal.BaseMPlan.writeValueUsingStrategy(BaseMPlan.java:307)
    at com.bea.xml.marshal.BaseMPlan.marshal(BaseMPlan.java:358)
    at com.bea.xml.marshal.MarshalContext.writeElementObjectOrHref(MarshalContext.java:426)
    at com.bea.xml.marshal.BaseMPlan.writeValueUsingStrategy(BaseMPlan.java:307)
    at com.bea.xml.marshal.BaseMPlan.marshal(BaseMPlan.java:349)
    at com.bea.xml.marshal.MethodMPlan.marshal(MethodMPlan.java:260)
    at com.bea.wlw.runtime.core.dispatcher.DispMessage.marshalXml(DispMessage.java:386)
    at com.bea.wlw.runtime.jws.request.MimeXmlResponse.writePart(MimeXmlResponse.java:105)
    at com.bea.wlw.runtime.jws.request.MimeXmlResponse.writeOutputPart(MimeXmlResponse.java:97)
    at com.bea.wlw.runtime.jws.request.MimeXmlResponse.setReturnValue(MimeXmlResponse.java:31)
    ... 22 more
    </detail>
    </error>
    "Deepak" <[email protected]> wrote:
    >
    >
    >
    Hi,
    I am trying to run a WebLogic 8.1 Workshop webservice using Tuxedo Controls.
    I
    am running in to an XML error:
    <faultcode>JWSError</faultcode>
    <faultstring>com.bea.xml.marshal.XmlEncodingException: Error writing
    XML stream:
    com.bea.xml.pure.XMLStreamException: Unable to write XML string which
    starts with
    the illegal XML char 0x0000</faultstring>
    <detail>
    If i look into the application server log file, It says:
    <FML32Deserializer::deserializeInteger>
    ####<Dec 19, 2003 1:25:00 PM CST> <Debug> <WLW> <centurytelweb> <cgServer>
    <ExecuteThread:
    '11' for queue: 'weblogic.kernel.Default'> <<anonymous>> <BEA1-0237CF026485B78A2335>
    <000000> <Exception deserializing field BUFFERSIZE, exception: weblogic.jws.control.ControlException:
    Error getting field BUFFERSIZE as a Integer, exception: 4 (FNOTPRES)>
    ####<Dec 19, 2003 1:25:00 PM CST> <Debug> <WLW> <centurytelweb> <cgServer>
    <ExecuteThread:
    '11' for queue: 'weblogic.kernel.Default'> <<anonymous>> <BEA1-0237CF026485B78A2335>
    <000000> <FML32Deserializer::deserializeField - Name=ROWID, type=class
    java.lang.String>
    But these fields are in the field table class file generated using java
    weblogic.wtc.jatmi.mkfldclass32

  • To Get the value of a node in a XML file which is outside the envelope

    Hi Everyone,
    I am uploading data in a XML file into Oracle tables. I am using oracle 9i release 2. How to get a value of a node outside the envelope.
    Here is my xml file.
    <Response>
    <TaskNo>14</TaskNor>
    <ZoneResponse>
    <GetServiceStatusResponse xmlns="http://mws.zonemws.com/Shipment/2010-10-01/">
    <GetServiceStatusResult>
    <Status>GREEN</Status>
    <Date>2011-06-03</Date>
    </GetServiceStatusResult>
    <Metadata>
    <Id>c9488a06</Id>
    </Metadata>
    </GetServiceStatusResponse>
    </ZoneResponse>
    </Response>
    This is the response xml we are getting from the supplier. I do want to store all the values in an oracle table, including TaskNo(14). TaskNo is the main value
    here. I am using dbms_xmlparser and dbms_xmldom in PL/SQL. I am able to get the values inside the envelope, but not the outside(taskno). It is not showing any errors. It is processing all
    other values. I Posted this in the XML DB section also. Please help me to solve this issue. Any help,tips and suggesstion will be highly appreciated. Thanks in advance
    --Vimal                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    I am providing some additional info like procedure, table structure and sample xml file so that you can get a clear idea about my problem and help me.
    My Procedure
    PROCEDURE xml_upload (
    p_directory IN VARCHAR2,
    p_server_directory IN VARCHAR2,
    p_filename IN VARCHAR2
    AS
    l_bfile BFILE;
    l_clob CLOB;
    l_parser DBMS_XMLPARSER.parser;
    l_doc DBMS_XMLDOM.domdocument;
    l_noderowset DBMS_XMLDOM.domnode;
    l_noderow DBMS_XMLDOM.domnode;
    l_nodecount NUMBER;
    l_Resultlist DBMS_XMLDOM.domnodelist;
    l_request_id VARCHAR2 (300);
    l_task_number NUMBER;
    l_tasknum_list DBMS_XMLDOM.domnodelist;
    l_service_list DBMS_XMLDOM.domnodelist;
    l_time_list     DBMS_XMLDOM.domnodelist;
    l_tasknode DBMS_XMLDOM.domnode;
    l_servicenode DBMS_XMLDOM.domnode;
    l_temp VARCHAR2 (1000);
    l_table_name VARCHAR2 (100);
    l_cmd_execution VARCHAR2 (1000);
    l_orig_file_with_path VARCHAR2 (1000);
    l_dest_file_with_path VARCHAR2 (1000);
    l_status custom.task_status.status%TYPE;
    l_time custom.task_status.timestamps%TYPE;
    l_rows NUMBER;
    l_message SYS.XMLTYPE;
    l_return_status NUMBER;
    TYPE tab_type IS TABLE OF custom.task_status%ROWTYPE;
    t_tab tab_type := tab_type ();
    PROCEDURE write_exception (
    p1_filename VARCHAR2,
    p_comments VARCHAR2,
    p_rows_created NUMBER
    IS
    BEGIN
    read_xml_file (p_directory, p_filename, l_message, l_return_status);
    -- Convert the xml to a clob
    l_clob := l_message.getclobval();
    -- Create a parser.
    l_parser := DBMS_XMLPARSER.newparser;
    -- Parse the document and create a new DOM document.
    DBMS_XMLPARSER.parseclob (l_parser, l_clob);
    l_doc := DBMS_XMLPARSER.getdocument (l_parser);
    -- Free any resources associated with the CLOB and Parser
    -- dbms_lob.freetemporary(v_clob);
    DBMS_XMLPARSER.freeparser (l_parser);
    l_noderowset :=
    DBMS_XMLDOM.item
    (DBMS_XMLDOM.getchildnodes (DBMS_XMLDOM.makenode (l_doc)),
    0
    l_nodecount :=
    DBMS_XMLDOM.getlength (DBMS_XMLDOM.getchildnodes (l_noderowset))
    - 1;
    t_tab.EXTEND;
    FOR i IN 0 .. l_nodecount
    LOOP
    l_noderow :=
    DBMS_XMLDOM.item (DBMS_XMLDOM.getchildnodes (l_noderowset), i);
    l_Resultlist :=
    DBMS_XMLDOM.getelementsbytagname
    (DBMS_XMLDOM.makeelement (l_noderow),
    'RequestId'
    l_request_id :=
    DBMS_XMLDOM.getnodevalue
    (DBMS_XMLDOM.getfirstchild
    (DBMS_XMLDOM.item (l_Resultlist,
    0
    END LOOP;
    FOR i IN 0 .. l_nodecount
    LOOP
    l_noderow :=
    DBMS_XMLDOM.item (DBMS_XMLDOM.getchildnodes (l_noderowset), i);
    l_service_list:=
    DBMS_XMLDOM.getelementsbytagname
    (DBMS_XMLDOM.makeelement (l_noderow),
    'Status'
    l_status:=
    DBMS_XMLDOM.getnodevalue
    (DBMS_XMLDOM.getfirstchild
    (DBMS_XMLDOM.item (l_service_list,
    0
    l_time_list:=
    DBMS_XMLDOM.getelementsbytagname
    (DBMS_XMLDOM.makeelement (l_noderow),
    'Timestamp'
    l_time:=
    DBMS_XMLDOM.getnodevalue
    (DBMS_XMLDOM.getlastchild
    (DBMS_XMLDOM.item (l_time_list,
    0
    END LOOP;
    select
    extractvalue(column_value,'/Response/TaskNumber') into l_task_number
    from
    table(xmlsequence(xmltype('<Response>
    <TaskNumber>14</TaskNumber>
    <ZoneResponse>
    <GetServiceStatusResponse xmlns="http://mws.zoneaws.com/InboundShipment/2010-10-01/">
    <GetServiceStatusResult>
    <Status>GREEN</Status>
    <Timestamp>2011-06-03T22:17:17.313Z</Timestamp>
    </GetServiceStatusResult>
    <Metadata>
    <RequestId>c9488a06-73c6-474e-b356-51d5f8feec00</RequestId>
    </Metadata>
    </GetServiceStatusResponse>
    </ZoneResponse>
    </Response>
    t_tab (t_tab.LAST).status:= l_status;
    t_tab (t_tab.LAST).timestamps:= l_time;
    t_tab (t_tab.LAST).amz_request_id:= l_request_id;
    t_tab (t_tab.LAST).tasknumber:= l_task_number;
    -- Insert data into the real Staging table from the table collection.
    FORALL i IN t_tab.first .. t_tab.last
    INSERT INTO custom.task_status VALUES t_tab(i);
    COMMIT;
    DBMS_XMLDOM.freedocument (l_doc);
    DBMS_LOB.freetemporary (l_clob);
    DBMS_XMLPARSER.freeparser (l_parser);
    DBMS_XMLDOM.freedocument (l_doc);
    DBMS_LOB.freetemporary (l_clob);
    DBMS_XMLPARSER.freeparser (l_parser);
    DBMS_XMLDOM.freedocument (l_doc);
    END rrs_xml_upload;
    Sample File:
    <Response>
    <TaskNumber>14</TaskNumber>
    <ZoneResponse>
    <GetServiceStatusResponse xmlns="http://mws.zoneaws.com/InboundShipment/2010-10-01/">
    <GetServiceStatusResult>
    <Status>GREEN</Status>
    <Timestamp>2011-06-03T22:17:17.313Z</Timestamp>
    </GetServiceStatusResult>
    <Metadata>
    <RequestId>c9488a06-73c6-474e-b356-51d5f8feec00</RequestId>
    </Metadata>
    </GetServiceStatusResponse>
    </ZoneResponse>
    </Response>
    Table: task_status
    tasknumber number,
    status varchar2(100),
    timestamps varchar2(100),
    requestid varchar2(100)
    all I want is to populate the data from xml file to the particulare table. I can do that with the above procedure.
    But In this below mentioned part of my procedure , I want to pass the file name instead of giving the entire content.
    select
    extractvalue(column_value,'/Response/TaskNumber') into l_task_number
    from
    table(xmlsequence(xmltype('<Response>
    <TaskNumber>14</TaskNumber>
    <ZoneResponse>
    <GetServiceStatusResponse xmlns="http://mws.zoneaws.com/InboundShipment/2010-10-01/">
    <GetServiceStatusResult>
    <Status>GREEN</Status>
    <Timestamp>2011-06-03T22:17:17.313Z</Timestamp>
    </GetServiceStatusResult>
    <Metadata>
    <RequestId>c9488a06-73c6-474e-b356-51d5f8feec00</RequestId>
    </Metadata>
    </GetServiceStatusResponse>
    </ZoneResponse>
    </Response>
    Alex or any other oracle pl/sql experts please help me to solve this issue.
    FYI : I am using Oracle 9.2.0.8.0
    Thanks,
    Vimal..
    Edited by: Vimal on Jun 13, 2011 4:10 PM

  • Which API can be used to write to an XML file(web.xml) programmatically

    Hi,
    I wish to write to the web.xml file programmatically.Could anyone point me to the
    API that is to be used.
    I am aware of the API to be used for extracting the node and the tag values - com.bea.p13n.xml.util.DomHelper
    but this class has only getters and I wish to know which API should be used to set
    the xml nodes.
    It is important and am looking forward to pointers.
    Thanks in advance!
    Regards,
    Shikha

    S. Bajaj
    org.w3c.dom Api
    Deepak
    shikha wrote:
    Hi,
    I wish to write to the web.xml file programmatically.Could anyone point me to the
    API that is to be used.
    I am aware of the API to be used for extracting the node and the tag values - com.bea.p13n.xml.util.DomHelper
    but this class has only getters and I wish to know which API should be used to set
    the xml nodes.
    I am unable to find answer to this.
    Looking forward to pointers and help.
    Thanks in advance!
    Regards,
    Shikha

  • How to binding incoming xml node list to the tree control as dataProvider

    Recently, I faced into one issue: I want to binding incoming xml node (it's not avaliable at start) list to the tree control as a dataProvider.
    Since the incoming xml node list is not avaliable at beginning but I needs to bind it to the tree, so I create one virtual one in the xml, and prepare to remove it before the tree is shown. (ready for the actual node adding). But It did not work.
    Please see the presudo-code here:
    1.  Model layer(CsModel.as)
    public class CsModel
            [Bindable]
            public var treeXML:XML=<nodes><car label="virtualOne" id="1">
                                   </car></nodes>;
            (Here, I want to build binding relationship on the <car/> node,
             one 'virtual/stub' node is set here with lable="virtualOne".
             But this node will be deleted after IdTree
             control is created completely.)      
            [Bindable]
            public var treeData:XMLList =new XMLListCollection(treeXML.car);
    2. view layer(treePage.mxml)
            private var _model:CsModel = new CsModel();
            private function addNode():void
                    var newNode:XML=<car/>;
                    newNode.@label="newOne";
                    newNode.@id=1;
                    _model.treeXML.appendChild(newNode);
                             private function cleanData():void
                                     delete _model.treeXML.car;
            <mx:VBox height="100%" width="100%">
            <mx:Button label="AddNode" click="addNode()" />
            <mx:Tree id="IdTree"  labelField="@label"
              creationComplete="cleanData()"
              dataProvider="{_model}"/>
        </mx:VBox>
    3. Top view layer (App.Mxml)
    <mx:application>
        <treePage />
    </mx:application>
    For method: cleanData(),It's expected that when the treePage is shown, we first delete the virutalOne to provide one 'clear' tree since we don't want show virtualOne to the user. The virutalOne node just for building the relationship between treeData and treeXML at beginning. But the side effect of this method, I found, is that the relationship between treeXML and treeData was cut off. And this leads to that when I added new node (by click the 'addNode' button) to the xmlXML, the xmlData was not affected at all !
    So Is there any other way to solve this issue or bind the incoming xml node list to the xmlListCollection which will be used as Tree control's dataProvider ?

    If u want to display the name : value then u can do like this
    <xsl:eval>this.selectSingleNode("name").nodeName</xsl:eval> : <xsl:value-of select="name" />

  • Can't convert string element to XML node using XSL

    We have a source XML with a node that contains another XML as string. Like this:
    "<imp1:payload>&lt;?xml version = '1.0' encoding = 'ISO-8859-15' standalone = 'no'?>
    &lt;!-- Oracle eXtensible Markup Language Gateway Server -->&lt;!DOCTYPE PROCESS_PO_007 SYSTEM "003_process_po_007.dtd">&lt;PROCESS_PO_007>&lt;CNTROLAREA>" etc
    And we have a target XML that has the schema inside the string in the source file, like this:
    "<PROCESS_PO_007>
    <CNTROLAREA>"....etc.
    How can we "parse" the string to a node using an XSL transformation file?

    Hi,
    Can you tell me which code are you using currently for transferrring the data? It might help me to figure out what your problem is.

  • Xml in JTree: how to not collpase JTree node, when renaming XML Node.

    Hi.
    I'm writing some kind of XML editor. I want to view my XML document in JTree and make user able to edit contents of XML. I made my own TreeModel for JTree, which straight accesses XML DOM, produced by Xerces. Using DOM Events, I made good-looking JTree updates without collapsing JTree on inserting or removing XML nodes.
    But there is a problem. I need to produce to user some method of renaming nodes. As I know, there is no way to rename node in w3c DOM. So I create new one with new name and copy all children and attributes to it. But in this way I got a new object of XML Node instead of renamed one. And I need to initiate rebuilding (treeStructureChanged event) of JTree structure. Renamed node collapses. If I use treeNodesChanged event (no rebuilding, just changes string view of JTree node), then when I try to operate with renamed node again, exception will be throwed.
    Is there some way to rename nodes in my program without collpasing JTree?
    I'am new to Java. Maybe there is a method in Xerces DOM implementation to rename nodes without recreating?
    Thanks in advance.

    I assume that "rename" means to change the element name? Anyway your question seems to be "When I add a node to a JTree, how do I make sure it is expanded?" This is completely concerned with Swing, so it might have been better to post it in the Swing forum, but if it were me I would do this:
    1. Copy the XML document into a JTree.
    2. Allow the user to edit the document. Don't attempt to keep an XML document or DOM synchronized with the contents of the JTree.
    3. On request of the user, copy the JTree back to a new XML document.
    This way you can "rename" things to the user's heart's content without having the problem you described.

Maybe you are looking for