Xml validation and transformation in a row: Possible?

Hi.
I'm working on a small tool that uses javax.xml.validation and javax.xml.transform (JDK 6) to perform validation and transformation of xml files in a row.
The problem is, the namespaces and reference to the xml schema required by the validator somehow prevent the transformation from extracting data from the xml file.
Here's the header I use in the xml file:
<tagWhatever
xmlns="http://www.myPlace.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myPlace.com mySchema.xsd">To sum it up, with the namespace declaration within the xml I can validate but not transform, and without the declaration, I can transform but not validate.
Can anyone help me out witht this one?
Thanks
5thString

Hi.
I'm working on a small tool that uses javax.xml.validation and javax.xml.transform (JDK 6) to perform validation and transformation of xml files in a row.
The problem is, the namespaces and reference to the xml schema required by the validator somehow prevent the transformation from extracting data from the xml file.
Here's the header I use in the xml file:
<tagWhatever
xmlns="http://www.myPlace.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myPlace.com mySchema.xsd">To sum it up, with the namespace declaration within the xml I can validate but not transform, and without the declaration, I can transform but not validate.
Can anyone help me out witht this one?
Thanks
5thString

Similar Messages

  • XML Messaging and JSP.  Is it possible?

    Here is my situation.
    We are developing JSP with a backend interface to external/remote Java/C++ applications. We like to implment, if possible, XML messaging between JSP and remote programs.
    First of all, is this possible? Can JAXM be used in JSP?
    Thanks in advance.

    Sure, but you might need to use polling for the JSP to get the response to show the user.

  • Load XML file and transform to table in database

    Hi All,
    If I have a xml file as sample xml data
    <EMPLOYEES>
    - <EMP>
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAME>
    <JOB>CLERK</JOB>
    <MGR>7902</MGR>
    <HIREDATE>17-DEC-80</HIREDATE>
    <SAL>800</SAL>
    </EMP>
    </EMPLOYEES>
    And I need to import to Emplyees table
    Create table Employees
    ( EMPNO number,
    ENAME varchar2(100),
    JOB varchar2(100),
    MGR number,
    HIREDATE date,
    SAL number
    How to import the xml file to the table?
    Regards,
    Hiko

    Well, if it's a complex XML you can use register a Schema and shred the XML to tables as described on the following thread:
    Re: XML file processing into oracle
    Or if it's fairly simple XML, you can just use XMLTABLE to flatten the data out...
    SQL> ed
    Wrote file afiedt.buf
      1  WITH xml_table AS
      2      (SELECT xmltype('
      3      <root>
      4        <child name="name1">
      5          <grandchild name="name11">
      6            <greatgrandchild name="name111"/>
      7            <greatgrandchild name="name112"/>
      8          </grandchild>
      9          <grandchild name="name12"/>
    10       </child>
    11       <child name="name2">
    12         <grandchild name="name21"/>
    13            <greatgrandchild name="name211"/>
    14         <grandchild name="name22"/>
    15       </child>
    16     </root>') object_value FROM dual)
    17     select po.child_name, gc.gchild_name, ggc.ggchild_name
    18     from   xml_table p
    19           ,xmltable('/root/child'
    20                     passing p.object_value
    21                     columns child_name  varchar2(100) path '@name'
    22                           ,gchild      xmltype       path 'grandchild'
    23                    ) po
    24           ,xmltable('/grandchild'
    25                     passing po.gchild
    26                     columns gchild_name varchar2(100) path '@name'
    27                            ,ggchild     xmltype       path 'greatgrandchild'
    28                   ) (+) gc
    29           ,xmltable('/greatgrandchild'
    30                     passing gc.ggchild
    31                     columns ggchild_name varchar2(100) path '@name'
    32*                  ) (+) ggc
    SQL> /
    CHILD_NAME           GCHILD_NAME          GGCHILD_NAME
    name1                name11               name111
    name1                name11               name112
    name1                name12
    name2                name21
    name2                name22and then insert the results into whatever table(s) you want.

  • XML Validation with multiple XSD files (referenced)

    Hello,
    I know that XML validation with version 7.1 is possible now. However I was provided with a set of XSD files that have references to each other and need to be placed in a hierachical file system order so that references can be resolved.
    An element <xsl:include schemaLocation="../../baseSchemas/baseSchema.xsd" /> is used for example. How can I handle that for XSD validation in PI? Can I create the same folder structure or do I need to put all XSD files in one directory and change the import manually?
    But most important question: Is it possible it all to use more than one XSD for schema validation?

    Dear Florian,
    I had encountered such case in a project.
    I was given 3 files. One main file and 2 others called Schema1.xsd and Schema2.xsd.
    This happens because your data type is not in single namespace, but is being referred across namespaces and software components.
    I am assuming that you have read the How to Guide for XML validations on PI 7.1
    Best way to do this quickly is as follows.
    1. Enable XML validation at adapter engine in the sender agreement.
    2. Post a message using HTTP post. (http://sappihttpclient.codeplex.com)
    3. Check communication channel in runtime workbench. There will be an error saying which is missing at what path.
    4. Create the path mentioned and place the file at that path.
    5. Repeat steps 2,3,4 for all the files.
    When you are done with this, you will get a proper validation error in case XML file is not correct. And remember to generate XSD from message type and not data type.
    Regards,
    Vikas
    Edited by: Vikas Aggarwal on Sep 2, 2009 8:45 PM
    Edited by: Vikas Aggarwal on Sep 2, 2009 8:48 PM

  • XML Validation with Java

    I have created a XML file with dom4j and the file confirmed to be valid when I read the file with Internet Explorer, a online XML validator and a free XML editor called "CookTop". However, when I attemp to read the XML file during the execution of an ant task I always get the XML parsing exception that one of my tag is not closed. I have even wrapped that test inside the tag as CDATA but that does not help as well. Do any one know what's happening? Here's my environment:
    JDK: 1.4.2_05
    Xerces: 2.6.2
    Ant: 1.5.3
    Thanks so much in advance.
    I've been pumping my head into the wall for hours : p

    Can i know where to download the CookTop?or CookTop2?

  • XML Validation in PI 7.1 - Restart and skip validation possible, but how?

    Hello all,
    I read about schema validation in PI 7.1 and did a few tests on my own, but could not restart and skip validation for invalid payloaded messages. The documents say it is possible.
    Anyone know how? Thanks.
    BTW, I really think putting the schemas in server file system will cause a lot of authorization trouble in enterprises. No one gives access to the server filesystem and I don't think they will also like to open the required subdirectories for share. Asking the basis team to create the folder structures and maintaining schemas would be another pain. Don't you also think that SAP could find a better approach, like automatically uploading the schemas to the filesystem, or validating them from repository directly if possible?
    Kind regards,
    Gökhan

    Hi Gökhan,
    I am facing the same issue.
    I set up outbound xml validation in receiver agreement and tested it with valid and invalid messages.
    The validation works fine.
    But in case of validation error I tried to restart with skipping the validation. But this wasn't possible.
    I am always facing the same valdiation error.
    I already tried all different tools I know (sxi_monitor, message monitoring in rwb and in nwa)
    I am working on PI 7.11 SP6
    Did you find a solution for skipping the validation for a single message out of the monitoring?
    I know that there is the possibility of deactivate the validation in receiver agreement but thid doesn't meet the requirement of skip the validation only for a single message.
    Maybe anyone else faced and solved this issue already.
    Thanks in advance
    Jochen

  • Across row validation in tabular form and across items in row validations.

    Hi,
    We are upgrading to APEX 4.0.
    I need to create a tabular form that will have a start date and an end date. FOr each new row or updated row I need ensure its start date is after the end date of all rows already entered and its end date is after the start date of row being entered. Also that if no end date is entered then no other rows can be found with a null end date.
    SO I need across field validations with in a row and across row validattions. That is I need rowset validations as well.
    Is it possible to do this with APEX? WHat kind of tabular solution would allow these type of validations. How might these validations be done?

    Okay, Here's a quick rundown on how to build a manual form using APEX_ITEM and collections. The process goes in 4 steps: gather the data, display the data, update based on user input, then write the changes. Each step requires it's own piece of code, but you can extend this out as far as you want. I have a complex form that has no less than a master table and 4 children I write to based on user input, so this can get as complex as you need. Let me know if anything doesn't make sense.
    First, create the basic dataset you are going to work with. This usually includes existing data + empty rows for input. Create a Procedure that fires BEFORE HEADER or AFTER HEADER but definitely BEFORE the first region.
    DECLARE
      v_id     NUMBER;
      var1     NUMBER;
      var2     NUMBER;
      var3     VARCHAR2(10);
      var4     VARCHAR2(8);
      cursor c_prepop is
      select KEY, col1, col2, col3, to_char(col4,'MMDDYYYY')
        from table1
        where ...;
      i         NUMBER;
      cntr      NUMBER := 5;  --sets the number of blank rows
    BEGIN
      OPEN c_prepop;
        LOOP
          FETCH c_prepop into v_id, var1, var2, var3, var4;
          EXIT WHEN c_prepop%NOTFOUND;
            APEX_COLLECTION.ADD_MEMBER(
            p_collection_name => 'MY_COLLECTION',
            p_c001 => v_id,  --Primary Key
            p_c002 => var1, --Number placeholder
            p_c003 => var2, --Number placeholder
            p_c004 => var3, --text placeholder
            p_c005 => var4 --Date placeholder
        END LOOP;
      CLOSE c_prepop;
      for i in 1..cntr loop
        APEX_COLLECTION.ADD_MEMBER(
            p_collection_name => 'MY_COLLECTION',
            p_c001 => 0, --designates this as a new record
            p_c002 => 0, --Number placeholder
            p_c003 => 0, --Number placeholder
            p_c004 => NULL, --text placeholder
            p_c005 => to_char(SYSDATE,'MMDDYYYY') --Date placeholder
      end loop;
    END;Now I have a collection populated with rows I can use. In this example I have 2 NUMBERS, a TEXT value, and a DATE value stored as text. Collections can't store DATE datatypes, so you have to cast it to text and play with it that way. The reason is because the user is going to see and manipulate text - not a DATE datatype.
    Now build the form/report region so your users can see/manipulate the data. Here is a sample query:
    SELECT rownum, apex_item.hidden(1, c001),  --Key ID
         apex_item.text(2, c002, 8, 8) VALUE1,
         apex_item.text(3, c003, 3, 3) VALUE2,
         apex_item.text(4, c004, 8, 8) VALUE3,
         apex_item.date_popup(5, null,c005,'MMDDYYYY',10,10) MY_DATE
    FROM APEX_COLLECTIONS
    WHERE COLLECTION_NAME = 'MY_COLLECTION'This will be a report just like an SQL report - you're just pulling the data from the collection. You can still apply the nice formatting, naming, sorting, etc. of a standard report. In the report the user will have 3 "text" values and one Date with Date Picker. You can change the format, just make sure to change it in all four procedures.
    What is critical to note here are the numbers that come right before the column names. These numbers become identifiers in the array used to capture the data. What APEX does is creates an array of up to 50 items it designates as F01-F50. The F is static, but the number following it corresponds to the number in your report declaration above, ie, F01 will contain the primary key value, F02 will contain the first numeric value, etc. While not strictly necessary, it is good practice to assign these values so you don't have to guess.
    One more note: I try to align the c00x values from the columns in the collection with the F0X values in the array to keep myself straight, but they are separate values that do NOT have to match. If you have an application you think might get expanded on, you can leave gaps wherever you want. Keep in mind, however, that you only have 50 array columns to use for data input. That's the limit of the F0X array even though a collection may have up to 1000 values.
    Now you need a way to capture user input. I like to create this as a BEFORE COMPUTATIONS/VALIDATIONS procedure that way the user can see what they changed (even if it is wrong). Use the Validations to catch mistakes.
    declare
      j pls_integer := 0;
    begin
    for j1 in (
      select seq_id from apex_collections
      where collection_name = 'MY_COLLECTION'
      order by seq_id) loop
      j := j+1;
      --VAL1 (number)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>2,p_attr_value=>wwv_flow.g_f02(j));
      --VAL2 (number)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>3,p_attr_value=>wwv_flow.g_f03(j));
      --VAL3 (text)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>4,p_attr_value=>wwv_flow.g_f04(j));
      --VAL4 (Date)
      apex_collection.update_member_attribute (p_collection_name=> 'MY_COLLECTION',
          p_seq=> j1.seq_id,p_attr_number =>5,p_attr_value=>wwv_flow.g_f05(j));
    end loop;
    end;Clear as mud? Walk through it slowly. The syntax tells APEX which Collection (p_collection_name), then which row (p_seq), then which column/attribute (p_attr_number) to update with which value (wwv_flow.g_f0X(j)). The attribute number is the column number from the collection without the "c" in front (ie c004 in the collection = attribute 4).
    The last one is your procedure to write the changes to the Database. This one should be a procedure that fires AFTER COMPUTATIONS AND VALIDATIONS. It uses that hidden KEY value to determine whether the row exists and needs to be updated, or new and needs to be inserted.
    declare
    begin
      --Get records from Collection
      for y in (select TO_NUMBER(c001) x_key, TO_NUMBER(c002) x_1,
                 TO_NUMBER(c003) x_2,
                 c004 x_3,
                 TO_DATE(c005,'MMDDYYYY') x_dt
               FROM APEX_COLLECTIONS
               WHERE COLLECTION_NAME = 'MY_COLLECTION') loop
        if y.x_key = 0 then  --New record
            insert into MY_TABLE (KEY_ID, COL1,
                COL2, COL3, COL4, COL5)
              values (SEQ_MY_TABLE.nextval, y.x_1,
                  y.x_2, y.x_3, y.x_4, y.x_dt);
        elsif y.x_key > 0 then  --Existing record
            update MY_TABLE set COL1=y.x_1, COL2=y.x_2,
                 COL3=y.x_3, COL4=y.x_4, COL5=y.x_dt
             where KEY_ID = y.x_key;
        else
          --THROW ERROR CONDITION
        end if;
      end loop;
    end;Now I usually include something to distinguish the empty new rows from the full new rows, but for simplicity I'm not including it here.
    Anyway, this works very well and allows me complete control over what I display on the screen and where all the data goes. I suggest using the APEX forms where you can, but for complex situations, this works nicely. Let me know if you need further clarifications.

  • ENTITIES and transforming XML to XML/HTML using XSL

    I am going absolutely nuts. When using XSL to transform an XML
    file to HTML or another XML schema, critical entities dissappear.
    For example:
    <oldtag>press &quot;any&quot; key</oldtag>
    will get rendered to
    <newtag>press "any" key</newtag>
    by the XML/XSL parser, which is not valid HTML or XML.
    How do I preserve these entities through the transformation
    process. Escaping the text (in the XML source) with <![CDATA[]]
    is not possible in this case.--Michael
    null

    Assuming you can't use a CDATA in the DTD to prevent parsing,
    then my suggestion would be to use the XSL stylesheet to restore
    the entities as there is no way that I am aware of that will set
    conditional expansion.
    Oracle XML Team
    http://technet.oracle.com
    Oracle Technology Network
    Michael Van Auken (guest) wrote:
    : I am going absolutely nuts. When using XSL to transform an
    XML
    : file to HTML or another XML schema, critical entities
    dissappear.
    : For example:
    : <oldtag>press &quot;any&quot; key</oldtag>
    : will get rendered to
    : <newtag>press "any" key</newtag>
    : by the XML/XSL parser, which is not valid HTML or XML.
    : How do I preserve these entities through the transformation
    : process. Escaping the text (in the XML source) with <![CDATA
    : > is not possible in this case.
    : --Michael
    null

  • XML ROWSET AND ROW...

    hi,
    declare
    tab_domicilios col_domicilios; -- col_domicilios is a collection type
    resul clob;
    begin
    -- select...
    bulk collect into tab_domicilios
    from...
    SELECT SYS_XMLAGG (SYS_XMLGEN (VALUE (x))).getclobval() INTO resul
    FROM TABLE (CAST (tab_domicilios AS col_domicilios)) x;
    bdms_output.put_line(resul);
    end;
    the resul value is:
    <?xml version="1.0"?>
    <ROWSET>
    <ROW>
    <ID>394</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <IDTIPODOMICILIO>1</IDTIPODOMICILIO>
    <NOMBRE>SAGUNTO</NOMBRE>
    <NUMERO>174</NUMERO>
    <RESTO>12 3</RESTO>
    <IDPOBLACION>28856</IDPOBLACION>
    <IDPERSONA>395</IDPERSONA>
    <TIPODOMICILIO>
    <ID>1</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <NOMBRE>Domicilio habitual</NOMBRE>
    </TIPODOMICILIO>
    <POBLACION>
    <ID>28856</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <IDPROVINCIA>45</IDPROVINCIA>
    <IDPAIS>1</IDPAIS>
    <NOMBRE>VALENCIA</NOMBRE>
    <COD_POSTAL>46009</COD_POSTAL>
    </POBLACION>
    <PAIS>
    <ID>1</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <NOMBRE>ESPAÑA</NOMBRE>
    <EUROPEO>S</EUROPEO>
    <CODIGOHACIENDA>ES</CODIGOHACIENDA>
    <PREFIJOTELEFONICO>34</PREFIJOTELEFONICO>
    </PAIS>
    <PROVINCIA>
    <ID>45</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <IDAUTONOMIA>11</IDAUTONOMIA>
    <NOMBRE>VALENCIA</NOMBRE>
    </PROVINCIA>
    </ROW>
    <ROW>
    <ID>559</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <IDTIPODOMICILIO>3</IDTIPODOMICILIO>
    <NOMBRE>Balmes</NOMBRE>
    <NUMERO>200</NUMERO>
    <IDPOBLACION>531</IDPOBLACION>
    <IDPERSONA>395</IDPERSONA>
    <TIPODOMICILIO>
    <ID>3</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <NOMBRE>Otras</NOMBRE>
    </TIPODOMICILIO>
    <POBLACION>
    <ID>531</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <IDPROVINCIA>6</IDPROVINCIA>
    <IDPAIS>1</IDPAIS>
    <NOMBRE>BADALONA</NOMBRE>
    <COD_POSTAL>08914</COD_POSTAL>
    </POBLACION>
    <PAIS>
    <ID>1</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <NOMBRE>ESPAÑA</NOMBRE>
    <EUROPEO>S</EUROPEO>
    <CODIGOHACIENDA>ES</CODIGOHACIENDA>
    <PREFIJOTELEFONICO>34</PREFIJOTELEFONICO>
    </PAIS>
    <PROVINCIA>
    <ID>6</ID>
    <ESTADOOBJETO>Original</ESTADOOBJETO>
    <IDAUTONOMIA>7</IDAUTONOMIA>
    <NOMBRE>BARCELONA</NOMBRE>
    </PROVINCIA>
    </ROW>
    </ROWSET>
    is possible change the name of ROW by FILA and ROWSET by GRAL
    thank's in advance

    SQL> SELECT SYS_XMLAGG (SYS_XMLGEN (VALUE (l),
                                   SYS.xmlgenformattype.createformat ('MY_EMP')
                       SYS.xmlgenformattype.createformat ('MY_ROWSET')
                      ) xml
      FROM TABLE (CAST (MULTISET (SELECT *
                                    FROM emp) AS emp_tab)) l
    WHERE ROWNUM <= 5
    XML                                              
    <?xml version="1.0"?>                            
    <MY_ROWSET>                                      
    <MY_EMP>                                         
      <EMPNO>7369</EMPNO>                            
      <ENAME>SMITH</ENAME>                           
      <JOB>CLERK</JOB>                               
      <MGR>7902</MGR>                                
      <HIREDATE>17-DEC-80</HIREDATE>                 
      <SAL>800</SAL>                                 
      <DEPTNO>20</DEPTNO>                            
    </MY_EMP>                                        
    <MY_EMP>                                         
      <EMPNO>7499</EMPNO>                            
      <ENAME>ALLEN</ENAME>                           
      <JOB>SALESMAN</JOB>                            
      <MGR>7698</MGR>                                
      <HIREDATE>20-FEB-81</HIREDATE>                 
      <SAL>1600</SAL>                                
      <COMM>300</COMM>                               
      <DEPTNO>30</DEPTNO>                            
    </MY_EMP>                                        
    <MY_EMP>                                         
      <EMPNO>7521</EMPNO>                            
      <ENAME>WARD</ENAME>                            
      <JOB>SALESMAN</JOB>                            
      <MGR>7698</MGR>                                
      <HIREDATE>22-FEB-81</HIREDATE>                 
      <SAL>1250</SAL>                                
      <COMM>500</COMM>                               
      <DEPTNO>30</DEPTNO>                            
    </MY_EMP>                                        
    <MY_EMP>                                         
      <EMPNO>7566</EMPNO>                            
      <ENAME>JONES</ENAME>                           
      <JOB>MANAGER</JOB>                             
      <MGR>7839</MGR>                                
      <HIREDATE>02-APR-81</HIREDATE>                 
      <SAL>2975</SAL>                                
      <DEPTNO>20</DEPTNO>                            
    </MY_EMP>                                        
    <MY_EMP>                                         
      <EMPNO>7654</EMPNO>                            
      <ENAME>MARTIN</ENAME>                          
      <JOB>SALESMAN</JOB>                            
      <MGR>7698</MGR>                                
      <HIREDATE>28-SEP-81</HIREDATE>                 
      <SAL>1250</SAL>                                
      <COMM>1400</COMM>                              
      <DEPTNO>30</DEPTNO>                            
    </MY_EMP>                                        
    </MY_ROWSET>                                     

  • REST API: Create Deployment throwing error BadRequest (The specified configuration settings for Settings are invalid. Verify that the service configuration file is a valid XML file, and that role instance counts are specified as positive integers.)

    Hi All,
    We are trying to access the Create Deployment method stated below
    http://msdn.microsoft.com/en-us/library/windowsazure/ee460813
    We have uploaded the Package in the blob and browsing the configuration file. We have checked trying to upload manually the package and config file in Azure portal and its working
    fine.
    Below is the code we have written for creating deployment where "AzureEcoystemCloudService" is our cloud service name where we want to deploy our package. I have also highlighted the XML creation
    part.
    byte[] bytes =
    new byte[fupldConfig.PostedFile.ContentLength + 1];
                fupldConfig.PostedFile.InputStream.Read(bytes, 0, bytes.Length);
    string a = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
    string base64ConfigurationFile = a.ToBase64();
    X509Certificate2 certificate =
    CertificateUtility.GetStoreCertificate(ConfigurationManager.AppSettings["thumbprint"].ToString());
    HostedService.CreateNewDeployment(certificate,
    ConfigurationManager.AppSettings["SubscriptionId"].ToString(),
    "2012-03-01", "AzureEcoystemCloudService", Infosys.AzureEcosystem.Entities.Enums.DeploymentSlot.staging,
    "AzureEcoystemDeployment",
    "http://shubhendustorage.blob.core.windows.net/shubhendustorage/Infosys.AzureEcoystem.Web.cspkg",
    "AzureEcoystemDeployment", base64ConfigurationFile,
    true, false);   
    <summary>
    /// </summary>
    /// <param name="certificate"></param>
    /// <param name="subscriptionId"></param>
    /// <param name="version"></param>
    /// <param name="serviceName"></param>
    /// <param name="deploymentSlot"></param>
    /// <param name="name"></param>
    /// <param name="packageUrl"></param>
    /// <param name="label"></param>
    /// <param name="base64Configuration"></param>
    /// <param name="startDeployment"></param>
    /// <param name="treatWarningsAsError"></param>
    public static
    void CreateNewDeployment(X509Certificate2 certificate,
    string subscriptionId,
    string version, string serviceName, Infosys.AzureEcosystem.Entities.Enums.DeploymentSlot deploymentSlot,
    string name, string packageUrl,
    string label, string base64Configuration,
    bool startDeployment, bool treatWarningsAsError)
    Uri uri = new
    Uri(String.Format(Constants.CreateDeploymentUrlTemplate, subscriptionId, serviceName, deploymentSlot.ToString()));
    XNamespace wa = Constants.xmlNamespace;
    XDocument requestBody =
    new XDocument();
    String base64ConfigurationFile = base64Configuration;
    String base64Label = label.ToBase64();
    XElement xName = new
    XElement(wa + "Name", name);
    XElement xPackageUrl =
    new XElement(wa +
    "PackageUrl", packageUrl);
    XElement xLabel = new
    XElement(wa + "Label", base64Label);
    XElement xConfiguration =
    new XElement(wa +
    "Configuration", base64ConfigurationFile);
    XElement xStartDeployment =
    new XElement(wa +
    "StartDeployment", startDeployment.ToString().ToLower());
    XElement xTreatWarningsAsError =
    new XElement(wa +
    "TreatWarningsAsError", treatWarningsAsError.ToString().ToLower());
    XElement createDeployment =
    new XElement(wa +
    "CreateDeployment");
                createDeployment.Add(xName);
                createDeployment.Add(xPackageUrl);
                createDeployment.Add(xLabel);
                createDeployment.Add(xConfiguration);
                createDeployment.Add(xStartDeployment);
                createDeployment.Add(xTreatWarningsAsError);
                requestBody.Add(createDeployment);
                requestBody.Declaration =
    new XDeclaration("1.0",
    "UTF-8", "no");
    XDocument responseBody;
    RestApiUtility.InvokeRequest(
                    uri, Infosys.AzureEcosystem.Entities.Enums.RequestMethod.POST.ToString(),
    HttpStatusCode.Accepted, requestBody, certificate, version,
    out responseBody);
    <summary>
    /// A helper function to invoke a Service Management REST API operation.
    /// Throws an ApplicationException on unexpected status code results.
    /// </summary>
    /// <param name="uri">The URI of the operation to invoke using a web request.</param>
    /// <param name="method">The method of the web request, GET, PUT, POST, or DELETE.</param>
    /// <param name="expectedCode">The expected status code.</param>
    /// <param name="requestBody">The XML body to send with the web request. Use null to send no request body.</param>
    /// <param name="responseBody">The XML body returned by the request, if any.</param>
    /// <returns>The requestId returned by the operation.</returns>
    public static
    string InvokeRequest(
    Uri uri,
    string method,
    HttpStatusCode expectedCode,
    XDocument requestBody,
    X509Certificate2 certificate,
    string version,
    out XDocument responseBody)
                responseBody =
    null;
    string requestId = String.Empty;
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
                request.Method = method;
                request.Headers.Add("x-ms-Version", version);
                request.ClientCertificates.Add(certificate);
                request.ContentType =
    "application/xml";
    if (requestBody != null)
    using (Stream requestStream = request.GetRequestStream())
    using (StreamWriter streamWriter =
    new StreamWriter(
                            requestStream, System.Text.UTF8Encoding.UTF8))
                            requestBody.Save(streamWriter,
    SaveOptions.DisableFormatting);
    HttpWebResponse response;
    HttpStatusCode statusCode =
    HttpStatusCode.Unused;
    try
    response = (HttpWebResponse)request.GetResponse();
    catch (WebException ex)
    // GetResponse throws a WebException for 4XX and 5XX status codes
                    response = (HttpWebResponse)ex.Response;
    try
                    statusCode = response.StatusCode;
    if (response.ContentLength > 0)
    using (XmlReader reader =
    XmlReader.Create(response.GetResponseStream()))
                            responseBody =
    XDocument.Load(reader);
    if (response.Headers !=
    null)
                        requestId = response.Headers["x-ms-request-id"];
    finally
                    response.Close();
    if (!statusCode.Equals(expectedCode))
    throw new
    ApplicationException(string.Format(
    "Call to {0} returned an error:{1}Status Code: {2} ({3}):{1}{4}",
                        uri.ToString(),
    Environment.NewLine,
                        (int)statusCode,
                        statusCode,
                        responseBody.ToString(SaveOptions.OmitDuplicateNamespaces)));
    return requestId;
    But every time we are getting the below error from the line
     response = (HttpWebResponse)request.GetResponse();
    <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <Code>BadRequest</Code>
      <Message>The specified configuration settings for Settings are invalid. Verify that the service configuration file is a valid XML file, and that role instance counts are specified as positive integers.</Message>
    </Error>
     Any help is appreciated.
    Thanks,
    Shubhendu

    Please find the request XML I have found it in debug mode
    <CreateDeployment xmlns="http://schemas.microsoft.com/windowsazure">
      <Name>742d0a5e-2a5d-4bd0-b4ac-dc9fa0d69610</Name>
      <PackageUrl>http://shubhendustorage.blob.core.windows.net/shubhendustorage/WindowsAzure1.cspkg</PackageUrl>
      <Label>QXp1cmVFY295c3RlbURlcGxveW1lbnQ=</Label>
      <Configuration>77u/PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0NCiAgKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KDQogIFRoaXMgZmlsZSB3YXMgZ2VuZXJhdGVkIGJ5IGEgdG9vbCBmcm9tIHRoZSBwcm9qZWN0IGZpbGU6IFNlcnZpY2VDb25maWd1cmF0aW9uLkNsb3VkLmNzY2ZnDQoNCiAgQ2hhbmdlcyB0byB0aGlzIGZpbGUgbWF5IGNhdXNlIGluY29ycmVjdCBiZWhhdmlvciBhbmQgd2lsbCBiZSBsb3N0IGlmIHRoZSBmaWxlIGlzIHJlZ2VuZXJhdGVkLg0KDQogICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioNCi0tPg0KPFNlcnZpY2VDb25maWd1cmF0aW9uIHNlcnZpY2VOYW1lPSJXaW5kb3dzQXp1cmUxIiB4bWxucz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9TZXJ2aWNlSG9zdGluZy8yMDA4LzEwL1NlcnZpY2VDb25maWd1cmF0aW9uIiBvc0ZhbWlseT0iMSIgb3NWZXJzaW9uPSIqIiBzY2hlbWFWZXJzaW9uPSIyMDEyLTA1LjEuNyI+DQogIDxSb2xlIG5hbWU9IldlYlJvbGUxIj4NCiAgICA8SW5zdGFuY2VzIGNvdW50PSIyIiAvPg0KICAgIDxDb25maWd1cmF0aW9uU2V0dGluZ3M+DQogICAgICA8U2V0dGluZyBuYW1lPSJNaWNyb3NvZnQuV2luZG93c0F6dXJlLlBsdWdpbnMuRGlhZ25vc3RpY3MuQ29ubmVjdGlvblN0cmluZyIgdmFsdWU9IkRlZmF1bHRFbmRwb2ludHNQcm90b2NvbD1odHRwcztBY2NvdW50TmFtZT1zaHViaGVuZHVzdG9yYWdlO0FjY291bnRLZXk9WHIzZ3o2aUxFSkdMRHJBd1dTV3VIaUt3UklXbkFrYWo0MkFEcU5saGRKTTJwUnhnSzl4TWZEcTQ1ZHI3aDJXWUYvYUxObENnZ0FiZnhONWVBZ2lTWGc9PSIgLz4NCiAgICA8L0NvbmZpZ3VyYXRpb25TZXR0aW5ncz4NCiAgPC9Sb2xlPg0KPC9TZXJ2aWNlQ29uZmlndXJhdGlvbj4=</Configuration>
      <StartDeployment>true</StartDeployment>
      <TreatWarningsAsError>false</TreatWarningsAsError>
    </CreateDeployment>
    Shubhendu G

  • How to validate and transform large (180M) xml files

    Hi:
    I've been looking at various ways to do this with oracle and am getting a bit lost in the sea of documentation and different ways to go about this. I was hoping that something like the XMLParser class and XMLTransform would be smart enough to handle large files by using SAX when it has to but I'm getting "too many nodes" when trying to transform a really large file. I've gotten oraxsl to handle it if I pass in the proper memory parameters on the command line but a) this will still have limits and b) I was trying to do this in a stored procedure which (I think) means I'm looking at XMLParser?
    I've also seen documentation on something called "Scalable DOM" but I think that's only in 11g? So I'm thinking I have to write a (Java?) stored procedure to loop through the top elements of this XML file (select extract(...)) and transform each node?
    I have the XML, XSD, and XSLT all in clob columns. What's the easiest/quickest path within Oracle to validate the XML against the xsd and translate source XML with XSL?
    I'm using Oracle 10gR2 on RH Linux.
    Thanks.

    So I'm thinking I have to write a (Java?) stored procedure to loop through the top elements of this XML file (select extract(...)) and transform each node? Here's something I've written a while back when I hit the same restrictions ("too many nodes") on 10.2.0.4.
    It takes XMLType as input parameters (but it's easy to adapt for CLOB), and streams the transformed XML directly into a file :
    create or replace and compile java source named ora_xslt_util as
    import oracle.xml.parser.v2.*;
    import oracle.xdb.XMLType;
    import java.io.*;
    import org.w3c.dom.*;
    public class oraXSL
    private static XMLDocument getXMLDocument(XMLType xml) throws Exception
        XMLDocument doc = null;
        DOMParser parser  = new DOMParser();
        parser.setValidationMode(oracle.xml.parser.v2.XMLParser.NONVALIDATING);
        parser.setPreserveWhitespace(true);
        parser.parse(new StringReader(xml.getStringVal()));
        doc = parser.getDocument();
        return doc;
    public static void transform(XMLType doc, XMLType xsl, String filename) throws Exception
        OutputStream os = new FileOutputStream(filename);
        XMLDocument xmldoc = getXMLDocument(doc);
        XMLDocument xsldoc = getXMLDocument(xsl);
        XSLProcessor xsp = new XSLProcessor();
        XSLStylesheet xss = xsp.newXSLStylesheet(xsldoc);
        xsp.processXSL(xss, xmldoc, os);
        os.close();
    }and the PL/SQL wrapper (originally part of a package) :
    PROCEDURE processXSL (
       p_xmldoc IN XMLType
    , p_xsldoc IN XMLType
    , p_filename IN VARCHAR2
    IS
    LANGUAGE JAVA NAME 'oraXSL.transform(oracle.xdb.XMLType,oracle.xdb.XMLType,java.lang.String)'
    ;

  • XML Validation using java for SQL Injection and script validation

    I have an input coming from xml file.
    I have to read that input and validate the input against sql injections and scripts.
    I require help now how to read this xml data and validate against the above two options.
    I am a java developer.
    in this context what is marshelling?

    http://www.ibm.com/developerworks/library/x-javaxmlvalidapi.html?ca=dgr-lnxw07Java-XML-Val
    http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/package-summary.html
    The following code validates the xml against a xml schema
    // define the type of schema - we use W3C:
    String schemaLang = "http://www.w3.org/2001/XMLSchema";
    SchemaFactory factory = SchemaFactory.newInstance(schemaLang);
    Schema schema = factory.newSchema(new StreamSource("sample.xsd"));
    Validator validator = schema.newValidator();
    // at last perform validation:
    validator.validate(new StreamSource("sample.xml"));Message was edited by:
    haishai

  • Write and transform to String XML

    I have a big trable.
    I dinamicly generate XML File and try to transform it to String. I use standart toString() method for root Element of XML Document.
    My data are in Windows-1251 encoding, but result String is in UTF-8 encoding.
    When I write dinamicly generated XML Document in File.
    I set encoding Windows-1251, but result is in UTF-8.
    PLEASE HELP ME!!!!!

    Well, regarding file encodings Java has a history and so does MS-Windows. I don't know all the details for the Russian (let's rather use the term Cyrillic from now on) encodings but I went through a similar problem with German and iso-8859-1 encoding. The problem was similar in that some characters above 127 got displayed as '?'.
    Java uses a default encoding which changed in versions later than 1.1.7 from iso-8859-1 to CP1252 (I assume that for Cyrillic that translates to iso-8859-5 and cp1251, respectively).
    Windows and DOS have a whole list of changes with respect to Cyrillian encodings: CP855, CP866 and finally CP1251, which is incompatible with both iso-8859-5 and ISO-IR-111 (aka KOI8).
    Since your characters are displayed as '?' it's very unlikely you'll see a UTF-8 encoding in your output file (with all due respect), it rather seems to be a mismatch between one of the iso encodings and CP1251, that's my guess.
    Anyways, let me describe my problem a bit, and hopefully you can deduce a solution for yours.
    My XML file contained character 129 (that's a u with two dots on top) and displaying as well as writing that character to a file put a '?' in its place. DOS ASCII editors (as well as older Windows editors) use iso-8859-1 and display and input character 129 correctly and when I used JSDK1.1.6 everything was fine. Now, Java assumes CP1251 and by forcing it to use iso-8859-1 I got input and output working just fine.
    Since I don't have a Cyrillic Windows version at my disposal I can't find out which encoding will work for you, but it has to do with the default encoding Java is using, not so much with the XML and its parsing.
    You can use the following test program to find out what the correct settings are. Play with the encoding settings (CP8xx, iso-8859-5, CP1251) until both input and output files are identical and contain the correct characters.
    import java.io.*;
    class x{
       public static void main(String[] args)
          try
             InputStreamReader  isr = new InputStreamReader(new FileInputStream("ascii.txt"), "iso-8859-1");
             OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("ascii_out.txt"), "iso-8859-1");
             char[] buf=new char[1024];
             int n;
             while((n=isr.read(buf,0,1024))!=-1)
                osw.write(buf,0,n);
             isr.close();
             osw.close();
          catch(Exception e)
             e.printStackTrace();
    }If you still have problems, please provide more information:
    1. encoding attribute you're setting in the XML file
    2. the default file encoding of your Java version (a system property) + JSDK version
    3. XML parser vendor + version
    4. What you exactly mean by "transform" (XSLT ? just outputting ?)
    5. Some code samples might help, too.
    Hope that helps,
    Good luck.
    P.S.
    Here are some links for info on character sets and encodings:
    http://czyborra.com/charsets/codepages.html
    http://czyborra.com/charsets/iso8859.html
    http://www.cl.cam.ac.uk/~mgk25/unicode.html

  • Valid and well Formed XML Schema

    OK I have a project that takes in a xml doc and a xml schema and checks if doc if valid for given schema
    how do i check if a xml schema doc is well formed and valid on its own

    Thanks very much for you reply.
    Howcome in the tool XMLSpy when you create a schema you can check it its both well formed, well thats ok
    and valid? you dont specify the xml doc.
    I have code written that accepts a shema and instance doc and that works grand.
    Just a general question.
    Thanks.

  • Is the transformation between XML document and 2 dimensions table important?

    To everyone:
    I am trying to write a paper on this topic.first ,i want to ask whether the transformation between XML data and table in RDBMS is important,because xml data is suitable to transfer from a point to another,but not for storage,so when the transfer begin a program(in DB2,the program is DB2 extender)should change the data format in table into a xml document.And vice versa,the destination point receive the xml document,maybe the same program would store it in table.
    so i wonder if such a program exists in the Oracle8i or later version,and the detail about how the program realizes above funciton.please tell me where can i find related paper or materials.
    thanks!

    To everyone:
    I am trying to write a paper on this topic.first ,i want to ask whether the transformation between XML data and table in RDBMS is important,because xml data is suitable to transfer from a point to another,but not for storage,so when the transfer begin a program(in DB2,the program is DB2 extender)should change the data format in table into a xml document.And vice versa,the destination point receive the xml document,maybe the same program would store it in table.
    so i wonder if such a program exists in the Oracle8i or later version,and the detail about how the program realizes above funciton.please tell me where can i find related paper or materials.
    thanks! That is all oracle XDK is for. You can transform query results to xml and xml back into RDBMS. Infact Oracle provides much more flexible way than a DB2 extender does. In DB2 you need to give a DAD before you get any XML. Oracle relies on the direct transformation of query results into XML and adds flexibility of XSL ontop of the data.
    You can get more information on XML technology section of OTN.
    Once you write the article can we get a chance to see it.

Maybe you are looking for