Query creating XML returns empty tags when no data

Hello everyone,
I have a problem that I just can't seem to solve.
I have the following query:
select
            xmlelement
               "users",
               xmlagg
                  xmlelement
                     "user",
                     xmlelement
                        "username",
                        e.pin
                     xmlagg
                        xmlelement
                           "details",
                           xmlforest
                              e.password as "password"
                             ,e.first_name as "forename"
                             ,e.surname as "surname"
                             ,'0' as "retired"
                             ,e.email_address as "email"
                             ,e.telephone_number as "phone"
                             ,'No External Ref' as "externalRef"
                             ,add_months(sysdate,+60) as "expiryDate"
            ) xml_out
         from   aqaost_examiners e
         group by e.pin;The query returns the XML in the desired structure.
But the problem I have is that when there is no data found by the query, I still get a single row returned with the following: <users></users>
I've tried so many things to try to have the query return nothing at all if there is no data to be found, but I just can't do it without something else going wrong (messing up the XML structure etc).
Please can someone help or point me in the right direction?
Thank you very much in advance!
Robin

odie_63 wrote:
Hi,
Peter,
It is the GROUP BY that does that.Actually no, the GROUP BY relates to the innermost XMLAgg and is mandatory if e.pin is not unique.
Leave it out, and you also seem to have one to many XMLAGG(?)That's assuming e.pin is unique in the table (which is probably a fair assumption in this case).
In fact, the behaviour comes from the topmost XMLAgg :
SQL> select xmlelement("users",
2           xmlagg(
3             xmlelement("user",
4               xmlelement("username", e.empno)
5             , xmlelement("details",
6                 xmlforest(
7                   e.ename as "name"
8                 , e.job as "job"
9                 )
10               )
11             )
12           )
13         ) xml_out
14  from scott.emp e
15  where 1 = 0
16  ;
XML_OUT
<users></users>As with other aggregate functions (like SUM or AVG) adding a GROUP BY 'something' solves the problem :
SQL> select xmlelement("users",
2           xmlagg(
3             xmlelement("user",
4               xmlelement("username", e.empno)
5             , xmlelement("details",
6                 xmlforest(
7                   e.ename as "name"
8                 , e.job as "job"
9                 )
10               )
11             )
12           )
13         ) xml_out
14  from scott.emp e
15  where 1 = 0
16  group by null
17  ;
no rows selectedRobin,
If the innermost XMLAgg is really necessary, then you can use a subquery :
select xmlelement("users", v.users)
from (
select xmlagg(
xmlelement("user",
xmlelement("username", e.empno)
, xmlagg(
xmlelement("details",
xmlforest(
e.ename as "name"
, e.job as "job"
) as users
from scott.emp e
group by e.empno
) v
where v.users is not null
Hello there,
Thank you very much! That sorted out the issue (adding the Group By Null)...it works a treat! I hadn't even considered that.
I didn't need the second XMLAGG in the end either, as I discovered when tinkering to try to sort the issue, but thank you for being so comprehensive with your reply.
Here is my finished result:
select xmlelement("users",
             xmlagg(
               xmlelement("user",
                 xmlelement("username", e.pin)
               , xmlelement("details",
                   xmlforest(
                              e.password as "password"
                             ,e.first_name as "forename"
                             ,e.surname as "surname"
                             ,'0' as "retired"
                             ,e.email_address as "email"
                             ,e.telephone_number as "phone"
                             ,'No External Ref' as "externalRef"
                             ,add_months(sysdate,+60) as "expiryDate"
          ).getclobval() xml_out
   from aqaost_examiners e
   group by null;Thank you so much again.
Robin

Similar Messages

  • How do we stop the XSL transform creating an empty tag when there is no inp

    Here is a way to stop the XSL transform from creating an empty tag when there is no input.
    1. Open the XSL Map in Jdev
    2. Go to the Design Tab
    3. Right click the tag in the target tree and select "Add XSL node -> xsl:if"
    4. Create a new link from the source tag (the same that is linked to the target tag) to the newly created xsl:if

    For anyone coming in to find this, I located my answer here:
    [Special Applet Attributes|http://java.sun.com/javase/6/docs/technotes/guides/plugin/developer_guide/special_attributes.html#codebase]
    Thanks for reading.
    Sorry for the interruption.

  • How can I control creation of empty tags when using ora:view syntax?

    I'm using XMLQuery and ora:view syntax to create xml resources in the database but I'd like to be able to prevent the creation of empty tags for null values in the table.
    CREATE OR REPLACE PROCEDURE proc_ctsi_build is
    XMLdoc XMLType;
    BEGIN
    DBMS_XDB.deleteResource('/public/CTSI/ctsi_phsall_rpt1.xml',1);
    SELECT XMLQuery(
    '<Progress_Report>
    <Personnel_Roster>
    {for $c in ora:view("CTSI_INVEST_SOURCE_V")
        let $username  := $c/ROW/COMMONS_USERNAME/text(),
    $expertise  := $c/ROW/AREA_OF_EXPERTISE/text()
         return
      <Investigator>
       <Commons_Username>{$username}</Commons_Username>
    <Area_of_Expertise>{$expertise}</Area_of_Expertise>
    </Investigator>}
    </Personnel_Roster>
    </Progress_Report>'
    RETURNING CONTENT) INTO XMLdoc FROM DUAL;
    IF(DBMS_XDB.CREATERESOURCE('/public/CTSI/ctsi_phsall_rpt1.xml', XMLdoc)) THEN
    DBMS_OUTPUT.PUT_LINE('Resource is created');
    ELSE
    DBMS_OUTPUT.PUT_LINE('Cannot create resource');
    END IF;
    COMMIT;
    END;
    In this example how can I prevent getting <Area_of_Expertise/> in my output when AREA_OF_EXPERTISE is null in the table?
    Thanks

    Hi,
    you can use if else conditions.
    {if ($expertise) then
    <Area_of_Expertise>{$expertise}</Area_of_Expertise>
    else ()}
    **not tested**
    Ants
    Message was edited by:
    Ants Hindpere

  • Creating XML file from ABAP internal table data....

    Hello,
    I am fethcing data froma  custom table and I have to write data in XMl format. Following is the XML format in which I want data. Is there any function module iN SAP which will help me in writing data from internal table to XML file ?
    <batch>
      <invoice>
        <StatusCode>10</StatusCode>
        <paymentamount>122.00</paymentamount>
         <ReferenceNumber>70980934</ReferenceNumber>
      </invoice>
      <invoice>
         <StatusCode>90</StatusCode>
        <paymentamount>122.00</paymentamount>
         <ReferenceNumber>70980934</ReferenceNumber>
      </invoice>
      <control>
        <InvoiceCount>2</InvoiceCount>
      </control>
    </batch>
    Please help.
    Regards,
    Jainam.

    I suggest you look into "simple transformations". That's SAP's most recent technology for such purposes, as far as I know.
    http://help.sap.com/abapdocu_70/en/ABENABAP_ST.htm
    Thomas

  • Tag Query History mode returning too many rows of data

    I am running a Tag Query from HQ to a plant site and want to limit the amount of data that returns to the minimum required to display trends on a chart.  The minimum required is subjective, but will be somewhere between 22 and 169 data points for a weeks data.  Testing and viewing the result is needed to determine what is an acceptable minimum. 
    I build a Tag Query with a single tag and set it to History Mode.  I set a seven day period going midnight to midnight.  And I set the row count to 22.  When I execute the query it returns 22 data points.  But when I go to visualization, I get 565 datapoints.  So obviously that is not what I want as I want a very slim dataset coming back from the IP21 server (to minimize the load on the pipe). 
    Any suggestions?

    Hi Michael,
    it looks to me like you have enabled the "Use Screen Resolution" option in your display template or in the applet HTML. Setting this option makes the display template fetch as many rows as there are pixels in the chart area. Like setting a rowcount in the applet HTML as a param, this will override any rowcount limitations you have set at the Query Template level...
    Hope this helps,
    Sascha

  • SQL query with parameter returns empty result set, please help !!!

    Hi there,
    When I use the following query :
    <sql:query var="beroepsthemas" >
    select *
    from beroepsthemas
    where beroepsthemaid = ?
    <sql:param value="12"/>
    </sql:query>
    When I want to browse the result set with :
    <c:forEach items="${beroepsthemas.rows}" var="rij">
    it shows no records. But it must return at least one.
    All my jsp pages with sql queries and parameters have the same problem.
    This is all on my test environment. I'm using Ubuntu 5.10, Netbeans5.0, JDK 1.5_06, application runs in Bundeled Tomcat 5.5.9, MySQL 4.1.12, mysql-connector3.1.6
    When the same code is run on the live environment, it works just fine.
    The difference is :
    Mysql 4.1.10a, tomcat5.5.9, mysql-connector3.1.6
    What can there be wrong !!

    When the same code is run on the live environment, it
    works just fine.
    The difference is :
    Mysql 4.1.10a, tomcat5.5.9, mysql-connector3.1.6
    I didn't catch this. I think you may need to update the database driver.

  • XQuery - Return empty tag

    Hi all,
    I have the following query:
    SELECT XMLElement("BEAVS",
    XMLAgg(
    XMLElement("BEAV",
    XMLForest(d.par_row_id NBEAV)
    ).getclobval() AS "BEAV_RESULT"
    FROM beav d
    The XMLElement "BEAV" doesn't return any values but I still need to have the tag <BEAV></BEAV>... anyone?
    Thank you,
    Pedro.

    Does something like this work.. I can't test since I don't have the table definitions or data...
        SELECT XMLElement
                 "BEAV_RESULT",
                 XMLForest
                   d.cod_boletim NBEAV,
                   d.cod_entidade_fiscalizadora ENTIDADE_FISCALIZADORA
                 XMLElement
                   "ERRO_FORMATO",        
                     SELECT XMLAgg
                              XMLElement
                                "ERRO",
                                XMLForest
                                  bb.cod_erro CODIGO_ERRO,
                                  bb.nome_erro DESCRICAO_ERRO
                       FROM TABLE(pc_aaa.fn_bbb(d.cod_acidente)) aa, table_b bb
                      WHERE aa.COLUMN_VALUE = bb.cod_erro
                        AND bb.tp_erro = 'M'
                 XMLELEMENT
                   "ERRO_LEVE",
                     SELECT XMLAgg
                              XMLElement
                                "ERRO",
                                XMLForest
                                  f.cod_erro CODIGO_ERRO,
                                  b.nome_erro DESCRICAO_ERRO
                       FROM table_b b, table_c f
                      WHERE b.cod_erro = f.cod_erro
                        AND f.cod_acidente = d.cod_acidente
                        AND b.tp_erro = 'L'
               ).getclobval()
          FROM table_a d
         WHERE xpto = 123456;

  • How to prevent setBoundingThemes returning null MBR when no data are found

    I am using setBoundingThemes method in MapViewer bean to zoom in to query results in a JDBCTheme. It is possible however that the JDBCTheme doesn't contain any data when no rows match the criteria. The result is that the other themes are queried without a filter and the overall map size is used (as the result of the mbr of all themes). This wouldn't be a problem if the theme_min_scale was considered, but it isn't, so all available data are rendered and this takes quite a while. Is there a way to set an alternative query window which will be used in case no rows are returned?
    To show the difference:
    Using a JDBCTheme with results:
    a valid mbr is found:Thu Jun 09 19:44:48 CEST 2005 FINEST [oracle.sdovis.MapMaker] mbr of all bounding themes: java.awt.geom.Rectangle2D$Double[x=5.03750183491323,y=52.05182293319411,w=0.12810743017353943,h=0.08182653361177472]
    the resulting query for the (predefined) LOCALROAD theme:Thu Jun 09 19:44:48 CEST 2005 FINEST [oracle.sdovis.theme.pgtp] [ LOCALROAD ]: 5.03750183491323,52.05182293319411,5.165609265086769,52.133649466805885
    Thu Jun 09 19:44:48 CEST 2005 FINEST [oracle.sdovis.theme.pgtp] [ LOCALROAD ]: SELECT ROWID, GEOM, 'CSX:L.ALLROADS', NAME, 'CSX:T.ROAD NAME', 1, ID FROM MN_NW WHERE MDSYS.SDO_FILTER(GEOM, MDSYS.SDO_GEOMETRY(2003, 8307, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(?, ?, ?, ?)), 'querytype=WINDOW') = 'TRUE'
    Using a JDBCTheme without results:
    a null mbr is foundThu Jun 09 19:48:34 CEST 2005 WARN [oracle.sdovis.MapMaker] Null MBR resulted from buildDataMBR(themes).
    the resulting query for the (predefined) LOCALROAD theme:Thu Jun 09 19:48:34 CEST 2005 FINEST [oracle.sdovis.theme.pgtp] [ LOCALROAD ]: -Infinity,-Infinity,NaN,NaN
    Thu Jun 09 19:48:34 CEST 2005 FINEST [oracle.sdovis.theme.pgtp] [ LOCALROAD ]: SELECT ROWID, GEOM, 'CSX:L.ALLROADS', NAME, 'CSX:T.ROAD NAME', 1, ID FROM MN_NW'
    and after that the mbr is made up out of all themes, resulting in a map of all available dataThu Jun 09 19:56:19 CEST 2005 FINEST [oracle.sdovis.MapMaker] mbr of all themes: java.awt.geom.Rectangle2D$Double[x=-0.5,y=-2.6605568400000004,w=11.025,h=58.665278322000006]
    Of course I could query the database first to find out if there are any geo data available, but I am hoping there's another way. Anybody who can help?
    Regards,
    Ida

    Hi Ida,
    I think just the size parameter with null mbr for the bounding theme won't help too much.
    We would need a reference point to be used with this size. This point we could get if we query the other themes, but as we don't have a reference mbr (the bounding theme mbr is null) this would be a full query on the other themes.
    We will discuss your suggestion of not rendering any theme and raising an exception if the mbr for the bounding theme returns null.
    Thanks.
    Joao

  • Function module table returning empty rows but export data is getting

    Hi,
    I am executing function module through JCO after setting importing parameter and when i retrieve the table i get table with empty data 0 rows but i am able get export parameter data . when execute the same function module in abap through sap gui i get table containing 5 rows. what may be the problem. please find below code 
          function = getDefaultJCoConnection().getJCoFunction("ZCRM_ICSS_PROJ_CUST_USR");
                function.getImportParameterList().getField("USER_ID").setValue("MLDL010");
                getDefaultJCoConnection().execute(function);
                exportTable = function.getTableParameterList().getTable("PROJCUSTLIST");
                int rowsNumber = exportTable.getNumRows(); // companies table number of rows
                log.error("rowsNumber----"+String.valueOf(rowsNumber));
      try
         if (rowsNumber > 0)
         int i = 0;
         do
         tempString="table valuesZCOMP_ID"(String)exportTable.getValue("ZCOMP_ID")"ZCOMP_SPC-"+(String)exportTable.getValue("ZCOMP_SPC")
                     + "table valuesZCOMP_DESC"(String)exportTable.getValue("ZCOMP_DESC")"ZPRICE-"(String)exportTable.getValue("ZPRICE")"---" ;
         log.error(tempString);
         while (exportTable.nextRow());
         catch (Exception th)
         log.error("The following error occured: while retrieving table values ", th);
    Do you have any idea where may be the problem
    Regards,
    Pavan
    Edited by: Pavan Reddy on Apr 10, 2010 4:46 PM

    Hi Pavan,
    This could be the case. The function module might be expecting a value converted into its format.
    By this, I mean that the function module might be expecting 0012345678 for 12345678 (Where data element of the ID is of type CHAR 10 ).
    Please check if it is so.
    Best Regards,
    Kris.

  • How to create primary on a column when redundant data is present

    I am interested to add primary key constraint on a column where repeated data is there without affecting the date how can I immplement this.
    Can any one help me in this regard.
    Thanks
    Sanjay

    If you have duplicated data and going to specify the primary key constraint on that data it's quite against RDBMS concepts and can't be considered as a relevant idea. Nevertheless Oracle provides you with such tricky method, but once again, it's NOT good idea, change your mind:
    SQL> create table t (x int);
    Table created.
    SQL> insert into t values(1);
    1 row created.
    SQL> insert into t values(1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t;
             X
             1
             1
    SQL> create index t_x on t(x);
    Index created.
    SQL> alter table t add primary key (x) novalidate;
    Table altered.
    SQL> insert into t values(1);
    insert into t values(1)
    ERROR at line 1:
    ORA-00001: unique constraint (ORACLE_OCM.SYS_C006647) violated
    SQL> insert into t values(2);
    1 row created.
    SQL> select * from t;
             X
             1
             1
             2In this case you have PK constraint and it affects all new DMLs, but
    in fact you can't rely on PK.
    Rgds.

  • How to generate empty tag using XMLForest

    Hi,
    I am creating an XML document using XMLAgg, XMLForest and XMlElement functions.
    At some point I have an XMLForest embedded in the other XMLForest
    XMLForest( e.indicator as "col1",
               e.participant_id as "col2",
      XMLForest( tableAlias.col11 as "address1",
                 tableAlias.col12 as "address2",            
               ) as "items",
    )           and within the last one I have some expressions which are empty, so the XML tags are not generated, however I have to have an empty tags:
    <address2></address2>I tried to replace an expression using "NVL" or "DECODE", but the results were the same.
    I also tried to replace an embedded XMLForest with an XMLElement :
    XMLForest( e.indicator as "col1",
               e.participant_id as "col2",
      *XMLElement("items"*
                 *XMLElement("address1"),*
                 *XMLElement("address2")*
               *) as "items",*)           however it created 2 <items> tags :
        <items>
             <items>
                <address1>value</address1>
                <address2></address2>
             </items>
         </items> I am working with Oracle 11.2.0 db.
    Is there any way to generate an empty tag when using XMLForest function?
    thank you in advance.
    Edited by: user624274 on Apr 3, 2013 8:52 AM
    Edited by: user624274 on Apr 3, 2013 8:53 AM

    Hello Odie_63.
    Your argument is valid, but it does not mean the solution I provided is bad.
    If you are concerned about the size of the result, it is simple, you can use like:
    REPLACE(XMLForest( NVL(e.indicator, '#NULLValue#') as "col1",  NVL(e.participant_id, '#NULLValue#') as "col2").getClobVal(), '#NULLValue#', '')
    According to Oracle documentation, REPLACE is smart and will return a CLOB (not a varchar2) because it changes the type of return according to the type of the first parameter. So you will not have issues with size.
    I believe the first question was related to use the final result to record to a table or send to another system (to use as integration). If it will be used just in a select field, it does not matter if it is not there or if it is there as NULL, the select of the field will always return ''.
    Other hint, I never use xmltype to store on database, because it is not compatible with other databases or integration tools. I use CLOB because it is the natural serialization of the object and I can convert and work with it inside and outside Oracle.
    But that is up to the architect and/or developer. If the system is running only on Oracle and there is no integration, maybe xmltype will save a lot of time in conversions.
    Regards.
    Rodolpho

  • Empty Tag in Site Report?

    Here's a line of code - one of several operating a menu system:
    <a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image3','','images\\m1_act.jpg',1)"></a>
    Why is DW 5.5 declaring this line as having an "empty tag" when I submit the page to DW Site Reporting?
    Here is a subsequent line in that same menu op that apparently passes muster.
    <a href="index-1.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image4','','images\\m2_act.jpg',1)"><img id="Image4" alt="" width="143" height="60" src="images\m2.jpg" /></a>
    Except for the <img> tag on the second, I don't see the difference.  I don't know what I'm missing....
    H

    File this under:
    Standing so close to the forest you can't see the trees...
    You're 100% correct.
    Thanks for helping a noob...
    Hoibie

  • SQLTables return empty

    Hi, all,
    I used to ues Microsoft ODBC driver for Oracle, my application works fine. Now, I switch to Oracle Driver for Oracle. My application does not work.
    It is becuase the "SQLTables" function returns empty recordset when I tried to look up tables. I am sure the table is there. Can anyone give me any clue? When I connect to the database, do I need special privilege?
    Thanks.
    Jing GUO

    Hi, there,
    When I connect to the database through ODBC, I use user "afm", and I am looking for a table named "bl" which belongs to schema "afm".
    the parameters are:
    cataloge name: ""
    schema name: ""
    table name "bl"
    tableType: ""
    And I also tried schema name: "AFM".
    Any clue? thanks
    Jing

  • Xslt copy-of creates a xml which returns empty while trying to access elements using XPATH

    Hi
    I am trying to do a copy-of function using the XSLT in jdev. This is what I do
        <xsl:param name="appdataDO"/>
        <xsl:template match="/">
        <ns1:applicationData>
          <ns1:applicationId>
            <xsl:value-of select="$appdataDO/ns1:applicationData/ns1:applicationId"/>
          </ns1:applicationId>
          <xsl:copy-of select="/fslo:ExternalapplicationData/fslo:ApplicationsHDRAddInfo">
          </xsl:copy-of>
        </ns1:applicationData>
        </xsl:template>
        </xsl:stylesheet>
    After this I can see the document created in the process flow as this :
        <ns1:applicationData>
        <ns1:applicationId>MMMM</ns1:applicationId>
        <ns2:ApplicationsHDRAddInfo>
        <ns3:genericFromBasePrimitive>iuoui</ns3:genericFromBasePrimitive>
        <ns4:EstimatedMarketValue>77</ns4:EstimatedMarketValue>
        <ns4:PropertyInsuranceFee>jih</ns4:PropertyInsuranceFee>
        <ns4:LoanOriginationFee>hjh</ns4:LoanOriginationFee>
        <ns4:RegistrarFee>kkkkk</ns4:RegistrarFee>
        <ns4:LoanCashInFee>hjh</ns4:LoanCashInFee>
        <ns4:LoanPaidInCashFlag>cddffgd</ns4:LoanPaidInCashFlag>
        </ns2:ApplicationsHDRAddInfo>
        </ns1:applicationData>
    But whenever I am trying to extract any of the output nodes I am getting an empty result. I can copy the whole dataset into similar kind of variable.
    But I am unable to get individual elements using XPATH.
    I tried using exslt function for node set and xslt 2.0 without avail.
    The namespaces might be the culprit here . The test method in the jdev is able to output a result but at runtime the xpath returns empty .
    I have created another transform where I try to copy data from the precious dataobject to a simple string in another data object .
    This is the test sample source xml for the transform created by jdev while testing with all namespaces, where I try to copy the data in a simple string in another data object.
        <applicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/bpmpa/fs/ulo/types file:/C:/JDeveloper/NewAPP/Xfrm/xsd/ApplicationData.xsd" xmlns="http://xmlns.oracle.com/bpmpa/fs/ulo/types">
           <applicationId>applicationId289</applicationId>
           <ApplicationsHDRAddInfo>
              <genericFromBasePrimitive xmlns="http://xmlns.oracle.com/bpm/pa/extn/types/BasePrimitive">genericFromBasePrimitive290</genericFromBasePrimitive>
              <EstimatedMarketValue xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">291</EstimatedMarketValue>
              <PropertyInsuranceFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">PropertyInsuranceFee292</PropertyInsuranceFee>
              <LoanOriginationFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">LoanOriginationFee293</LoanOriginationFee>
              <RegistrarFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">RegistrarFee294</RegistrarFee>
              <LoanCashInFee xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">LoanCashInFee295</LoanCashInFee>
              <LoanPaidInCashFlag xmlns="http://xmlns.oracle.com/bpm/pa/extn/headerCategories/">LoanPaidInCashFlag296</LoanPaidInCashFlag>
           </ApplicationsHDRAddInfo>
        </applicationData>
    And the xslt
        <xsl:template match="/">
            <ns1:DefaultOutput>
              <ns1:attribute1>
                <xsl:value-of select="/fslo:applicationData/fslo:ApplicationsHDRAddInfo/custom:LoanOriginationFee"/>
              </ns1:attribute1>
            </ns1:DefaultOutput>
          </xsl:template>
    This results in a empty attribute1. Any help will be appreciated .

    Please delete attributeFormDefault="qualified" elementFormDefault="qualified" from your XSD
    Please check the next link:
    http://www.oraclefromguatemala.com.gt/?p=34

  • Is there a way to modify the style sheet so that it transforms an XML document with empty tags as tag / ?

    I have extracted some code from codeproject to
    reindent an XML document. Does anyone know how I can modify the stylesheet to make it so that the transform of an XML file will result in empty tags showing up as <tag /> instead of <tag></tag>?
    // http://www.codeproject.com/Articles/43309/How-to-create-a-simple-XML-file-using-MSXML-in-C
    MSXML2::IXMLDOMDocumentPtr FormatDOMDocument(MSXML2::IXMLDOMDocumentPtr pDoc)
    LPCSTR const static szStyleSheet =
    R"!(<?xml version="1.0" encoding="utf-8"?>)!"
    R"!(<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">)!"
    R"!( <xsl:output method="xml" indent="yes"/>)!"
    R"!( <xsl:template match="@* | node()">)!"
    R"!( <xsl:copy>)!"
    R"!( <xsl:apply-templates select="@* | node()"/>)!"
    R"!( </xsl:copy>)!"
    R"!( </xsl:template>)!"
    R"!(</xsl:stylesheet>)!";
    MSXML2::IXMLDOMDocumentPtr pXmlStyleSheet;
    pXmlStyleSheet.CreateInstance(__uuidof(MSXML2::DOMDocument60));
    pXmlStyleSheet->loadXML(szStyleSheet);
    MSXML2::IXMLDOMDocumentPtr pXmlFormattedDoc;
    pXmlFormattedDoc.CreateInstance(__uuidof(MSXML2::DOMDocument60));
    CComPtr<IDispatch> pDispatch;
    HRESULT hr = pXmlFormattedDoc->QueryInterface(IID_IDispatch, (void**)&pDispatch);
    if (SUCCEEDED(hr))
    _variant_t vtOutObject;
    vtOutObject.vt = VT_DISPATCH;
    vtOutObject.pdispVal = pDispatch;
    vtOutObject.pdispVal->AddRef();
    hr = pDoc->transformNodeToObject(pXmlStyleSheet, vtOutObject);
    //By default it is writing the encoding = UTF-16. Let us change the encoding to UTF-8
    // <?xml version="1.0" encoding="UTF-8"?>
    MSXML2::IXMLDOMNodePtr pXMLFirstChild = pXmlFormattedDoc->GetfirstChild();
    // A map of the a attributes (vesrsion, encoding) values (1.0, UTF-8) pair
    MSXML2::IXMLDOMNamedNodeMapPtr pXMLAttributeMap = pXMLFirstChild->Getattributes();
    MSXML2::IXMLDOMNodePtr pXMLEncodNode = pXMLAttributeMap->getNamedItem(_T("encoding"));
    pXMLEncodNode->PutnodeValue(_T("UTF-8")); //encoding = UTF-8
    return pXmlFormattedDoc;
    Or, if there is some other method for reindenting a MSXML2::IXMLDOMDocumentPtr object where I can specify how I want empty tags to be stored, that would be great too.  However, I don't want it to lose its status of an MSXML2::IXMLDOMDocumentPtr object.
     I.e. I would like to still perform operations on the result as if it was still an MSXML2::IXMLDOMDocumentPtr object.
    Thanks,
    A
    Adrian

    If anyone is interested, I got an answer on StackOverflow
    here.
    Adrian

Maybe you are looking for

  • Oracle Report in Apex

    Dear all, I have existing jsp report that was developed with Oracle Report. Is it possible to reuse the report in Apex?. If so how? Thanks. Regards, Kueh.

  • What does 7.3.1 fix?

    I looked at the download, and the file size is the same as 7.3. Are the security issues outlined here resolved? http://www.news.com/8301-10784_3-9823040-7.html?tag=cd.blog

  • Can we have MRP Exclude a PO Line?

    We have a a PO that was negotiated for a specific project. The PO has common items that are used on other BOM's. MRP is seeing this PO as supply for all BOM's and we are wondering if there is any way to have MRP Exclude certain PO lines? We do not ha

  • Deploy applications to portal cluster

    Hi, We plan to build a ative-ative HA framework with two portal instances(OC4j_Portal) and these two instances are in different machines. My questions are as follows. 1) Is that necessary to add <distributable/> to all my web applications? 2) Should

  • I'm having problems with forgotten id and password

    I had an Ipod but had to sell it because of childrens needs and now I cant remember either user name or passwords and I have had to create a new account and have lost all the music that I have purchased over the last year ...