How to suppress an empty tag in the XML

Hi gurus,
Please help me with this problem. A part of my XML output looks like this,
<ParentElement>
<ChildElement>The Data</ChildElement>
<ChildElement>The Data</ChildElement>
</ParentElement>
This is produced in a select XMLAgg() statement from a table. If the table has one or more rows, I get the above result. But if there is no data in the table, I will get
<ParentElement/>. But the schema is such that if the ParentElement is there, it requries at least one ChildElement so the XML file does not validate. Is there a way to suppress the ParentElement when there is no data in the table? Or should the schema be changed?
Thanks a lot.
Ben

Thank you very much for your fast response. Here is the code that I use to generate the XML. At issue is the "PersonPhysicalFeature" element.
create or replace function fnGetLivescanDataForBCA (
     p_BookingNo     in     varchar2,
     p_MniID          in     number
return Clob
as
     v_XMLForBCA                    Clob := null;
     v_BookingAgencyORI      constant     varchar2(10) := '0620000';
     v_DateFormat          constant     varchar2(10) := 'mm/dd/yyyy';
     v_DateTimeFormat     constant     varchar2 (25) := 'mm/dd/yyyy hh24:mi';
     v_BCADateFormat          constant     varchar2(10) := 'yyyymmdd';
     v_UnknownBOP          constant     varchar2(2) := 'XX';
     v_UnknownCC          constant     varchar2(2) := 'XX';
     v_XMLFile                    XMLType;
     v_created                    boolean := false;
     --- BCA insists on having the XML prolog
     v_XMLProlog constant varchar2(100) := '<?xml version="1.0" encoding="UTF-8"?>' || utl_tcp.CRLF ;     
begin
     select XMLElement("BookSubject",
          XMLForest('DAVE FENNER' as "AttentionPerson"),
          XMLElement("AttentionOrganization",
               XMLForest(v_BookingAgencyORI as "OrganizationORIID")
          XMLForest('N' as "PalmprintAvailableIndicator",
               'Y' as "ArrestPhotoAvailableIndicator",
               'ARMED AND DANGEROUS' as "IdentificationComments",
               'N' as "InterstateCustodyTransferInd",
               '192.168.95.11' as "SourceComputerSystemAddress"),
          XMLElement("Booking",
               XMLForest(to_char(b.arrival_date, v_BCADateFormat ) as "ActivityDate"),               
               XMLElement("BookingAgencyRecordID",
                    XMLForest(substr(b.booking_no, 1, 4) || substr(b.booking_no, 7,6) as "ID")                         
               XMLElement("BiometricDeviceRecordID",
                    XMLForest(b.booking_no as "ID")
               XMLElement("BookingAgency",
                    XMLForest(v_BookingAgencyORI as "OrganizationORIID")
               XMLElement("BookingSubject",
                    (select XMLElement("PersonName",
                              XMLForest(substr(first_name, 1, 30) as "PersonGivenName",
                                   substr(middle_name, 1,30) as "PersonMiddleName",
                                   substr(last_name,1, 30) as "PersonSurName")
                         from name
                         where mni_id = p_MniID
                         ),-- end of select name                    
                    (select XMLElement("PersonBirthDate",
                              to_char(m.dob, v_BCADateFormat)
                         from name m                         
                         where m.mni_id = p_MniID                    
                         ), -- end of select alias
                    (select XMLAgg(
                              XMLElement("PersonBirthDate",
                                   to_char(ma.alias_dob, v_BCADateFormat)
                         ) -- end of XMLAgg - required for multiple rows     
                         from name_alias ma     
                         where ma.mni_id = p_MniID
                         ), -- end of select alias dob
                    (select XMLElement("PersonBirthLocationCode",
                              NVL(m.birth_state, v_UnknownBOP))
                         from name m
                         where m.mni_id = p_MniID
                         ), -- end of select birth state
                    XMLElement("PersonAssignedIDDetails",
                         (select XMLElement("PersonSSNID",
                                   XMLForest(m.ssn as "ID")
                              from name m
                              where m.mni_id = p_MniID
                              ), -- end of select name.ssn     
                         (select XMLAgg(
                                   XMLElement("PersonSSNID",
                                        XMLForest(ms.ssn as "ID")
                                   ) -- end of XMLAgg
                              from name_ssn ms
                              where ms.mni_id = p_MniID and rownum <= 3               
                              ), -- end of select alias SSN
                         (select XMLElement("PersonOtherID",
                                   XMLElement("ID", m.slco_pin),
                                   XMLElement("IDSourceOrganization",
                                        XMLForest(v_BookingAgencyORI as "OrganizationORIID")
                              from name m
                              where m.mni_id = p_MniID
                              ), -- end of select name.slco_pin as OtherID
                         XMLElement("BookingAgencyPersonID",
                              XMLForest('123456789' as "ID",
                                   'RCSO Some ID' as "IDTypeDescriptionText"),
                              XMLElement("IDSourceOrganization",
                                   XMLForest(v_BookingAgencyORI as "OrganizationORIID")
                              ) -- end of BookingAgencyPersonID
                         ), -- end of ID Details     
                    (select XMLElement("PersonPhysicalDetails",
                              XMLForest(m.eye_color as "PersonEyeColorCode",
                                   m.hair_color as "PersonHairColorCode",
                                   m.sex as "PersonSexText",
                                   m.race as "PersonRaceCode"),                              
                              XMLElement("PersonPhysicalFeature",
                                   (select XMLAgg(
                                             XMLElement("PhysicalFeatureDescriptionText",
                                                  substr(smt.bodypart || ' ' || smt.description, 1, 10)
                                                  ) -- end of feature desc text
                                             ) -- end of XMLAgg
                                        from name_smt smt
                                        where smt.mni_id = p_MniID and rownum <= 10
                                        ) -- end of select smt
                                   ), -- end of element physical feture                              
                              XMLElement("PersonHeightMeasure",
                                   XMLForest(NVL(to_char(m.height_feet), '0') || lpad(NVL(to_char(m.height_inches), '0'), 2, '0') as "Measure")
                                   ), --- end of height                         
                              XMLElement("PersonWeightMeasure",
                                   XMLForest(m.weight as "Measure")
                                   ) -- end of weight
                              ) -- end of first element                         
                         from name m
                         where m.mni_id = p_MniID
                         ), -- end of select physical details
                    (select XMLElement("PersonBiometricDetails",
                              XMLelement("PersonFingerprintSet",
                                   XMLForest(Decode(m.PERSONTYPE, 1, 'A', 2, 'J', 3, 'C', 'A')
                                   as "BiometricDescriptionText")
                                   ) -- end of second element
                              ) -- end of first element
                         from name m
                         where m.mni_id = p_MniID
                         ), -- select PersonType               
                    (select XMLAgg(
                              XMLElement("PersonAlias",
                              XMLElement("PersonName",
                                   XMLForest(substr(ma.first_name, 1, 30) as "PersonGivenName",
                                   substr(ma.middle_name, 1, 30) as "PersonMiddleName",
                                   substr(ma.last_name, 1, 30) as "PersonSurName"))
                              ) -- end of element
                         ) -- end of AMLAgg
                         from name_alias ma
                         where ma.mni_id = p_MniID
                         ), -- end of select name_alias
                    XMLElement("SubjectSupervision",
                         XMLElement("SupervisionSubjectStatus",
                              XMLForest(to_char(b.date_booked, v_BCADateFormat) as "StatusDate",
                                   'FROM RAMSEY COUNTY LEC' as "StatusDescriptionText")
                         ) -- end pf element subject supervision
                    ---XMLelement("PersonCitizenshipCode",
                    --     v_UnknownCC
                    --     ) -- end of element
                    ), -- end of BookingSubject
                    XMLElement("TreatAsAdultIndicator", 'Y'),
                    (select XMLAgg(
                              XMLElement("BookingCharge",
                                   XMLElement("ChargeText", substr(ct.statute_no, 1, 25)),
                                   XMLElement("ChargeDescriptionText", substr(trim(ct.charge), 1, 60)),
                                   XMLElement("ChargeClassification",
                                        XMLForest(ct.class as "ChargeDegreeText")),
                                   XMLElement("ChargeInstrument",
                                        XMLElement("DocumentDescriptiveMetadata",
                                             XMLForest(ct.complaint_no as "DocumentID"))),
                              ---     XMLElement("ChargeSentence", ' '),     --- do not include
                                   XMLElement("ChargeStatute",
                                        XMLForest('C' as "StatuteOffenseCode")),
                                   XMLElement("ChargeCommentsText", substr(ct.comments, 1, 50)),
                                   XMLElement("OffenseDate",
                                        to_char(NVL(ad.ucr_reported_date, ad.date_arrested), v_BCADateFormat)),
                                   XMLElement("ChargeOriginatingAgencyRID", ct.complaint_no),
                                   XMLElement("ChargeOriginatingAgency",
                                        XMLForest(ct.originating_agency as "OrganizationORIID")
                                   XMLElement("ArrestDispositionText", '205')
                         ) -- end of XMLAgg
                         from charges_temp ct
                         where ct.booking_no = p_BookingNo and ct.charge is not null
                              and length(ct.complaint_no) <= 8
                         ), -- end of select charges
               XMLElement("ArrestAgency",
                    XMLForest(NVL(ad.arresting_agency, v_BookingAgencyORI) as "OrganizationORIID"))
               ), --- end of Booking
          XMLElement("BCACriminalHistoryRequestInd", 'N'),
          XMLElement("FBICriminalHistoryRequestInd", 'N'),
          XMLElement("WantWarrantSearchRequestInd", 'N')
          ) into v_XMLFile      --- .getClobVal() into v_XMLForBCA --- v_XMLFile      ----- end of BookSubject
     from Booking b
     inner join arrest_affidavit ad
     on b.booking_no = ad.booking_no     
     where b.booking_no = p_BookingNo;
     ---v_created := DBMS_XDB.createResource('/public/' || p_BookingNo || '.xml', v_XMLFile);
     v_XMLForBCA := v_XMLFile.getClobVal();
     v_XMLForBCA := v_XMLProlog || v_XMLForBCA;     
     v_XMLFile.isSchemaValid('http://isora1.co.ramsey.mn.us:8080/sys/schemas/SSI/Schema.xsd');
     if v_XMLFile.isSchemaValid = 1 then
          dbms_output.put_line('XML is valid');
     else
          dbms_output.put_line('XML is not valid');
     end if;
     return v_XMLForBCA;
exception
     when others then
          dbms_output.put_line(SQLErrM(SQLcode));
          return null;
end fnGetLivescanDataForBCA;
/

Similar Messages

  • How to remove the header tag in the XML data ?

    Hi All,
    I am sending an XML data from SFTP to Proxy, in that I want to remove the header tag (first tag) from the xml, while loading the data. how to do that ?

    Hi,
          It is not about the thing that, whether your source is XML or flat file. If you dont want some thing in your source file , dont consider it and dont map it with your target structure. think that, your not getting the header in your source.  What is the header here.
    <Emp_details>
    <Emp_Id> Employee No </Emp_Id>
    <Emp_Name> Employee Name </Emp_Name>
    </Emp_details>
    <Emp_details>
    <Emp_Id> 1234 </Emp_Id>
    <Emp_Name> xxxx </Emp_Name>
    </Emp_details>
    <Emp_details>
    <Emp_Id> 5678 </Emp_Id>
    <Emp_Name> yyy </Emp_Name>
    </Emp_details>
    you have two fields under node Emp_details. What do u want to avoid here?
    Regards,
    Reyaz

  • Puttin the name of the file in one tag of the xml message

    Hi all,
    does anybody kowns how to put the name of the file in one tag of the xml message in the adapter, without using a java mapping to get the file name.
    Thanks.

    H Antonio,
    You can  use ASMA( Adapter Specific Message Attributes) for acccessing the file name, along with Dynamic Configuration. You can follow the following blog for that. If you do not want to use the same file name for the reciever, dont select the File Name check box.
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    Thanks and Regards,
    Sanjeev.

  • Regarding  the rowset and row tags in the XML output

    Hi,
    We generated an XML file using dataset of type SQL query.The output is including additional tags
    <ROWSET> and <ROW> tags.How to disable them from appearing in the XML output.

    Hi,
    Iam not using the Datamodel of data template type.If we use the data template we can disable the rowtags by setting the property mentioned by you.But we get the data template name and the query name included in the output.My requirement is to disable the extratags.
    Can u please provide inputs on how to disable the datatemplate name and the query name tags in the output when we use datatemplate.Thank you.

  • How to write adapter module to convert the xml to pdf file

    Hi all,
      how to write adapter module to convert the xml to pdf file.
    Please any body assist step by step procedure.

    PI 7.1 XML to PDF transformation
    have you seen below links:
    http://forums.sdn.sap.com/thread.jspa?threadID=1212478
    http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14363

  • How to remove empty tags respecting the schema contraints?

    Hi,
    I'm generating an XML document with XSLT. This document have some empty tags. My question is about to remove all empty tags only if they are defined as optionnals in the schema.
    Is this possible with the DOM?
    Thanks in advance,
    Philippe

    With DOM3 validation api, elements/attributes may be checked if they may be removed.
    -Check if the element is empty; getFirstChild() method returns null.
    -Check if the element may be removed with DOM 3 Validation API.

  • How to deal with empty tags in a SAX Parser

    Hi,
    I hope someone can help me with the problem I am having!
    Basically, I have written an xml-editor application. When an XML file is selected, I parse the file with a SAX parser and save the start and end locations of all the tags and character data. This enables me to display the xml file with the tags all nicely formatted with pretty colours. Truly it is a Joy To Behold. However, I have a problem with tags in this form:
    <package name="boo"/>
    because the SAX parser treats them like this:
    <package name = boo>
    </package>
    for various complex reasons the latter is unaccetable so my question is: Is there some fiendishly clever method to detect tags of this type as they occur, so that I can treat them accordingly?
    Thanks,
    Chris

    I have spent some time on googling for code doing this, but found nothing better, than I had to write in by myself.
    So, it would be something like this. Enjoy :)
    package comd;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.SAXException;
    import org.xml.sax.Attributes;
    import java.util.Stack;
    import java.util.Enumeration;
    public class EmptyTagsHandler extends DefaultHandler {
         private StringBuilder xmlBuilder;
         private Stack<XmlElement> elementStack;
         private String processedXml;
         private class XmlElement{
              private String name;
              private boolean isEmpty = true;
              public XmlElement(String name) {
                   this.name = name;
              public void setNotEmpty(){
                   isEmpty = false;
         public EmptyTagsHandler(){
              xmlBuilder = new StringBuilder();
              elementStack = new Stack();
         private String getElementXPath(){
              StringBuilder builder = new StringBuilder();
              for (Enumeration en=elementStack.elements();en.hasMoreElements();){
                   builder.append(en.nextElement());
                   builder.append("/");
              return builder.toString();
         public String getXml(){
              return processedXml;
         public void startDocument() throws SAXException {
              xmlBuilder = new StringBuilder();
              elementStack.clear();
              processedXml = null;
         public void endDocument() throws SAXException {
              processedXml = xmlBuilder.toString();
         public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
              if (!elementStack.empty()) {
                   XmlElement elem = elementStack.peek();
                   elem.setNotEmpty();
              xmlBuilder.append("<");
              xmlBuilder.append(qName);
              for (int i=0; i<attributes.getLength();i++){
                   xmlBuilder.append(" ");
                   xmlBuilder.append(attributes.getQName(i));
                   xmlBuilder.append("=");
                   xmlBuilder.append(attributes.getValue(i));
              xmlBuilder.append(">");
              elementStack.push(new XmlElement(qName));
         public void endElement(String uri, String localName, String qName) throws SAXException {
              XmlElement elem = elementStack.peek();
              if (elem.isEmpty) {
                   xmlBuilder.insert(xmlBuilder.length()-1, "/");
              } else {
                   xmlBuilder.append("</");
                   xmlBuilder.append(qName);
                   xmlBuilder.append(">");
              elementStack.pop();
         public void characters(char ch[], int start, int length) throws SAXException {
              if (!elementStack.empty()) {
                   XmlElement elem = elementStack.peek();
                   elem.setNotEmpty();
              String str = new String(ch, start, length);
              xmlBuilder.append(str);
         public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
              String str = new String(ch, start, length);
              xmlBuilder.append(str);
    }

  • How to use two group tags in the header?

    I am using BI Publishing,RTF Template,I found when I put two group tags before <?start:body?> ,the BI Publishing only keep the 2nd group tag right before <?start:body?> as header, it moved the 1st group tag to the body section.
    Is this a bug? Can anyone give me some ideas how to make BI Publish treat all the group tags before <?start:body?> as the header/sub header?
    thanks for your help

    Hi dirk,
    Thanks it worked well.
    I have one question for you in the tabular form.
    i have totally 10 columns in my tabular form, in that 9 column is of database column and only one column is non-database column, while updating the row in the tabular form it is throwing the below error like
    Current version of data in database has changed since user initiated update process. current row version identifier = "A0FD649E5A28DF9244990A3B9368298A" application row version identifier = "44CE02A233595BCA6F7D4A140BD4DF30" (Row 1)I thought the above error is due to the existence of non-database column in my tabular form. Is there any way to solve this issue. I need to have a non-database column in my tabular form but the presence of that column is not allowing to perform update in that tabular form.
    how to get rid of this issue dirk.
    Any ideas??
    Brgds,
    Mini

  • How to show an empty line at the end of a ParagraphView

    Hi everybody,
    I wonder if anyone knows how to extend ParagraphView to show an empty line at the end of every paragraph?
    Thanks in advance,
    mrai

    I tried to use that class and couldn't get it to work.
    JTextField field = new JTextField();
    field.setText("blah blah");
    CompisiteView view = new ParagraphView(field.getDocument().getRootElement());
    int views = view.getViewCount() //always zero...

  • How to put color combination like red/blue tag in the XML file

    Hi experts,
    i have developed one program to capture some DATA in one internal table.it contains 2 fields called addition flag and dedletion flag.then i have wriiten the following code for converting  the XML file for the above internal table data.i am passing this internal table in the following FM ''SDIXML_DATA_TO_DOM'.But as per our requirement,they need the REd color tag for addition flag and blue Color tag for the deletion flag in the Above XML File for the respective addition data item and deletion data item.how to do???
    Any suggestion can be Appreciated.its very urgent
    Thanx in advance.
    Regards,
    HPP.
    The code is wriiten for converting internal table to XML file.
    DATA: l_dom TYPE REF TO if_ixml_element,
      m_document TYPE REF TO if_ixml_document,
      g_ixml TYPE REF TO if_ixml,
      w_string TYPE xstring,
      w_size TYPE i,
      w_result TYPE i,
      w_line TYPE string,
      it_xml TYPE dcxmllines,
      s_xml LIKE LINE OF it_xml,
      w_rc LIKE sy-subrc.
      DATA: xml TYPE dcxmllines.
      DATA: rc TYPE sy-subrc,
      BEGIN OF xml_tab OCCURS 0,
      d LIKE LINE OF xml,
      END OF xml_tab.
    *XML conversion -internal table to XML Format.
      CLASS cl_ixml DEFINITION LOAD.
      g_ixml = cl_ixml=>create( ).
      CHECK NOT g_ixml IS INITIAL.
      m_document = g_ixml->create_document( ).
      CHECK NOT m_document IS INITIAL.
      WRITE: / 'Converting DATA TO DOM 1:'.
      CALL FUNCTION 'SDIXML_DATA_TO_DOM'
        EXPORTING
          name         = 'it_prop'
          dataobject   = it_prop[]
        IMPORTING
          data_as_dom  = l_dom
        CHANGING
          document     = m_document
        EXCEPTIONS
          illegal_name = 1
          OTHERS       = 2.
      IF sy-subrc = 0.
        WRITE 'Ok'.
      ELSE.
        WRITE: 'Err =',
        sy-subrc.
      ENDIF.
      CHECK NOT l_dom IS INITIAL.
      w_rc = m_document->append_child( new_child = l_dom ).
      IF w_rc IS INITIAL.
        WRITE 'Ok'.
      ELSE.
        WRITE: 'Err =',
        w_rc.
      ENDIF.
      CALL FUNCTION 'SDIXML_DOM_TO_XML'
        EXPORTING
          document      = m_document
        IMPORTING
          xml_as_string = w_string
          size          = w_size
        TABLES
          xml_as_table  = it_xml
        EXCEPTIONS
          no_document   = 1
          OTHERS        = 2.
      IF sy-subrc = 0.
        WRITE 'Ok'.
      ELSE.
        WRITE: 'Err =',
        sy-subrc.
      ENDIF.
      LOOP AT it_xml INTO xml_tab-d.
        APPEND xml_tab.
      ENDLOOP.
      CALL FUNCTION 'WS_DOWNLOAD'
        EXPORTING
          bin_filesize = w_size
          filename     = 'C:\prop.XML'
          filetype     = 'BIN'
        TABLES
          data_tab     = xml_tab
        EXCEPTIONS
          OTHERS       = 10.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

    TailOfGon wrote:
    Do you want to extract all the data with type='unknown'?
    Then try the XPath like this: 
    resource[type='unknown']/code
    Hi,
    Yes I want to extract all the data of the type = "unknown", I tried Xpath resource[type='unknown']/code but it didnt work , I still getting all other data of different type .
    Thanks,
    Ankit G

  • How to pull the root level XML tags in the XML source-SSIS?

    Hi All,
    Can anyone please help out with the following requirement?
    There is a XML file data which I need to pull it to database. Please see the attached XML file.
    Question: When I am trying to pull the root level data (i.e. CreationDateTime and FileNumber) from XML source in the dataflow, the respective tag is not seen in the input. Can anyone help me how can I get those values in my input to pull the data to Database?
    Thanks & Regards,
    Sri

    Hi Sri,
    In SQL Server Integrated Services, we can generate XML Schema (XSD) file based on a XML file with XML Source Editor. For more details, please refer to the following steps:
    Double-click the XML Source in the Data Flow Task. 
    Browse the XML file for the XML location.
    Click the Generate XSD button to generate an XSD file.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How about adding a meta tag to the index file.....

    This is another way to get verified with Google and other search engines. Does anyone know a way that you could add a meta tag to the index file generated by iweb??
    Thanks for any help....Matt
    http://www.want2takecredit.com

    I'm glad it worked. Nevertheless you might think of uploading an html file as well. The index.html sometimes gets overwritten by iweb, thus the meta-tag would disappear and you would have to do it again. The html file instead stays where it is.
    Here's how to procede:
    When they will ask you to verify that it really is your website. “Choose verification method” select “Upload an HTML file” and now you will have to build that verification file (here’s a How-to by Roddy).
    1. Go to your applications folder and launch Text Edit.
    2. Don't put anything on the blank page.
    3. Select File/Save As.
    4. In the popup window "Save As" box enter your Google number (something like google05a23d347cXXXXXX )
    5. In the "Where" box select desktop.
    6. In "File Format" menu select HTML.
    7. Click "Save".
    8. A file will appear on your desktop called google05a23d347cXXXXXX.html
    9. This is what you upload to your server or iDisk.
    Upload that file to your main folder on your server so that it will be http://www.yoururl.com/google05a23d347cXXXXXX.html (not in the subfolder of the Sites folder named with the title of your site...*).
    For .Mac go to the Finder menu and select Go/iDisk/My iDisk/ or hit SchiftCommand(Apple)i and then go to /Web/Sites/. Drop your file into the "Sites" folder
    Entering: http://web.mac.com/username/google05a23d347cXXXXXX.html in your browser should bring up this file. If it doesn’t you placed the file in the wrong location.
    Entering: http://yourbaseurl.com/google05a23d347cXXXXXX.html in your browser should bring up this file. If it doesn’t you placed the file in the wrong location.
    Regards,
    Cédric
    +I just noticed your other posts on the forum and that you got it solved I'll leave the explanation for other people wondering and stumbling over the thread+

  • How do I delete some text in a tag in the XML file?

    I need help with removing some text inside the tags so I can use it as a XMLfile
    string example
    Code
    <Event xmlns="http://SwitchKing.Common/Entities/RESTSimplified/2010/07" >
    <Description i:nil="true"/>
    So these are the tags inside the file that is stopping my work. 
    I cant seem to find a way to remove the xmlns.... or the i:nil...
    The i:nil gives of a error when trying to read the file and the xmlns stops the search for other tags in the file.
    So when I have loaded the data I need to delete some text in the tags.
    Help!

    If you want to delete photo stream photos, just deleted them from your device and they will be deleted from iCloud and your other devices.  Be sure you don't want them as you cannot get them back once you delete them.

  • How to parse all the data of the particular tag in the xml file

    Hi All,
    I have a xml file, which have tags like, code,rev_num,type...volunteer.I want to parse the xml and save the all data(code,rev_num...) of the tag <type>unknown </type>in a text file. I tried to use a Match node vi but I not geting the output i need.attach is my attempt , can anyone suggest me or help me out.(Sorry Cant attach the xml hence i saved it as an text file.)
    Thanks,
    Ankit G
    Solved!
    Go to Solution.
    Attachments:
    teeth.txt ‏385 KB
    Xml parse.vi ‏22 KB

    TailOfGon wrote:
    Do you want to extract all the data with type='unknown'?
    Then try the XPath like this: 
    resource[type='unknown']/code
    Hi,
    Yes I want to extract all the data of the type = "unknown", I tried Xpath resource[type='unknown']/code but it didnt work , I still getting all other data of different type .
    Thanks,
    Ankit G

  • Instance variable to hold the element of a tag in the xml file

    Hi I have an xml file that is handled using this parser
    <attr id="MY_NAME" >
    this parser hanled the above tag but now I want to have it handle
    <attr id="MY_NAME" desc="GOOD">
    but I need to create an instance variable to handle the desc element in the attr tag .
    Can some one help me out as this is not my file and I am having trouble to do please......
    import java.util.*;
    import java.io.*;
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
       The SupportMatrix class provides static variables and methods to simplify
       the determination of whether or not a given attribute is supported for a
       certain object type (queue manager, channel, etc.), depending on the version
       and platform of the queue manager to which it belongs.
       The SupportMatrix class may not be instantiated. Its constructor is private.
       An instance of the class is created internally in the static initializer so
       that the XML parsing methods are available.
       A corresponding XML document, SupportMatrix.xml, is parsed to create the various
       HashMaps which contain the version/platform dependency information. A number of
       inner classes are used to represent the various elements of the XML matrix
       definition.
       Here's a sample document:
       <!-- The supportmatrix tag opens the document -->
       <supportmatrix>
         <!-- Objects are keyed by classid. "1" is the classid of a queue manager object. -->
         <object classid="1">
           <!-- Versions group attributes according to the queue manager version where they
                were introduced. The "base" cmdlevel encompasses all versions up to 5.1. -->
           <version cmdlevel="base">
             <!-- Attributes are defined by the attr tag. -->
             <attr id="MQCA_Q_MGR_NAME">
               <!-- Support elements define the platform-specific requirements for an attribute. -->
               <support platforms="UNIX,WINDOWS,OS400,VMS,NSK" maxlen="48" type="MQCFST"/>
               <support platforms="MVS" maxlen="4" type="MQCFST"/>
             </attr>
             <attr id="MQCA_Q_MGR_DESC">
               <!-- Specific attribute characteristics, most notably maximum len for string parms,
                    are defined in the support element. As shown in the following example, it may
                    apply to all platforms. -->
               <support platforms="all" maxlen="64" type="MQCFST"/>
             </attr>
             <!-- Support elements are optional. -->
             <attr id="MQIA_PLATFORM"/>
             <attr id="MQIA_COMMAND_LEVEL"/>
           </version>
           <!-- The version element may 'include' other versions. Note that object elements
                may also refer to other objects via the 'include' parm of the object tag.
                This is to allow common attributes (especially for queues and channels) to
                be shared by multiple definitions in order to reduce some of the
                redundancy. -->
           <version cmdlevel="520" include="base">
           </version>
         </object>
       </supportmatrix>
       The inner classes, and their hierarchical relationships are as follows:
         SupportObject - corresponds to the <object> element. Stored in a static HashMap, and
                         keyed by classid.
           VersionObject - corresponds to the <version> element. Stored in a HashMap instance
                           variable of the SupportObject class, keyed by cmdlevel.
             AttributeObject - corresponds to the <attr> element. Stored in a HashMap instance
                               variable of the VersionObject class, keyed by attribute name.
               PlatformObject - corresponds to the <support> element. Stored in HashMaps belonging
                                to the AttributeObjects, keyed by platform. A single PlatformObject
                                instance is created when the support tag is encountered. The
                                "platforms" attribute of the support element is then processed. For
                                each platform in the comma-delimited list, an entry is added to the
                                collection of PlatformObjects. This is to greatly simplify later
                                lookups.
       In order to support the 'include' feature of object and version elements, certain
       functions are recursive. If the attribute to be validated is not found for the passed
       cmdlevel, the 'parent' VersionObject is consulted by means of the 'include' value. If
       the chain of VersionObjects has been exhausted and the attribute in question has still not
       been located, the next SupportObject in the chain is consulted in a similar fashion.
    public class SupportMatrix extends DefaultHandler {
        /** The objects collection holds all the SupportObjects, keyed by classid. */
        private static HashMap objects;
        /** xmlFile will name the xml document to be parsed. Note that using the
            default class loader expects the string to be the path to the file. It must
            NOT begin with the '/' character. */
        private static String xmlFile =
            ResourceManager.getApplicationProperties().getProperty("SupportMatrixFile");
        private Stack stack;
        /** This static initializer allocates the static objects collection, creates an
            instance of the SupportMatrix class for xml parsing purposes, and initiates
            the parse operation to populate the collection. */
        static {
            objects = new HashMap();
            // Create a parser and process the xml doc
            SupportMatrix handler = new SupportMatrix();
            InputSource is = null;
            try {
                is = new InputSource(ClassLoader.getSystemClassLoader().getResourceAsStream(xmlFile));
                XMLReader xmlReader =
                    SAXParserFactory.newInstance().newSAXParser().getXMLReader();
                xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
                xmlReader.setContentHandler(handler);
                if (is == null) {
                    System.err.println("No input stream, dammit");
                xmlReader.parse(is);
            } catch(Exception e) {
                e.printStackTrace();
        /** Private constuctor, used only for XML parsing. */
        private SupportMatrix() {
            stack = new Stack();
        /** Add a SupportObject instance to the objects collection. */
        private void addObject(SupportObject obj) {
            String key = obj.getClassId();
            objects.put(key, obj);
        /* DefaultHandler methods                                              */
        /** Not used. */
        public void characters(char[] ch, int start, int length) {}
        /** Not used. */
        public void endDocument() {}
        /** For the version, object, and attr elements, pop the top element of the stack. */
        public void endElement(String uri, String localName, String qName) {
            if (localName.equals("version") || localName.equals("object") || localName.equals("attr")) {
                stack.pop();
        /** Not used. */
        public void setDocumentLocator(Locator locator) {}
        /** Not used. */
        public void startDocument() {}
        /** Most of the work is done here. Create the appropriate inner class instance for
            element; for object, version, and attr, push the element onto the stack so that
            child elements may be added to their collections as needed. */
        public void startElement(String uri, String localName, String qName,
                                 Attributes attributes) {
            String include = attributes.getValue("include");
            if (localName.equals("object")) {
                SupportObject obj = new SupportObject(attributes.getValue("classid"), include);
                addObject(obj);
                stack.push(obj);
            } else if ( localName.equals("version")) {
                VersionObject ver = new VersionObject(attributes.getValue("cmdlevel"), include);
                ((SupportObject)stack.peek()).addVersion(ver);
                stack.push(ver);
            } else if ( localName.equals("attr")) {
                AttributeObject a = new AttributeObject(attributes.getValue("id"));
                //String desc = StringFactory.getString(attributes.getValue("desc"));
                //if(desc != null)
                   //     a.setAttribute();
                String readonly = attributes.getValue("readonly");
                String exclude = attributes.getValue("exclude");
                if (include != null && exclude != null) {
                    Log.log(Log.ERROR, this, "include and exclude are mutually exclusive, exclude value ignored");
                    exclude = null;
                if (include != null) {
                    a.setCondition(include, true);
                if (exclude != null) {
                    a.setCondition(exclude, false);
                if (readonly != null)
                    a.setReadonly(readonly.equals("y"));
                ((VersionObject)stack.peek()).addAttr(a);
                stack.push(a);
            } else if (localName.equals("support")) {
                String platforms = attributes.getValue("platforms");
                String readonly = attributes.getValue("readonly");
                String maxlen = attributes.getValue("maxlen");
                String type = attributes.getValue("type");
                int attrType = 0;
                if (type != null) {
                    if (type.equals("MQCFIN")) {
                        attrType = CMQCFC.MQCFT_INTEGER;
                    } else if (type.equals("MQCFIL")) {
                        attrType = CMQCFC.MQCFT_INTEGER_LIST;
                    } else if (type.equals("MQCFST")) {
                        attrType = CMQCFC.MQCFT_STRING;
                    } else if (type.equals("MQCFSL")) {
                        attrType = CMQCFC.MQCFT_STRING_LIST;
                    } else if (type.equals("EXBIN")) {
                        attrType = MqcConstants.EXCFT_BINARY;
                    } else if (type.equals("EXPCF")) {
                        attrType = MqcConstants.EXCFT_PCF;
                PlatformObject p = null;
                if (readonly == null) {
                    p = new PlatformObject(platforms);
                } else {
                    p = new PlatformObject(platforms, readonly.equals("y"));
                String exclude = attributes.getValue("exclude");
                if (include != null && exclude != null) {
                    Log.log(Log.ERROR, this, "include and exclude are mutually exclusive, exclude value ignored");
                    exclude = null;
                if (include != null)
                    p.setCondition(include, true);
                if (exclude != null)
                    p.setCondition(exclude, false);
                if (attrType != 0)
                    p.setType(attrType);
                if (maxlen != null)
                    p.setLen(Integer.parseInt(maxlen));
                ((AttributeObject)stack.peek()).addPlatform(p);
        public static boolean isExported(int attribute, TopologyModelNode node) {
            String name = ResourceManager.getAttributeName(attribute);
            return isExported(name, node);
        public static boolean isExported(String attribute, TopologyModelNode node) {
            // Find the qmgr node to fetch platform and cmdlevel
            TopologyModelNode qmgr = node.getModel().getQMgrNode(node.getAddress());
            // If there's no qmgr for this node, it must be one of 'ours'.
            if (qmgr == null)
                return false;     // None of 'our' objects can be exported to MQSC.
            String classId = node.getClassId();
            String cmdLevel = qmgr.getAttributeValue("MQIA_COMMAND_LEVEL");
            String platform = qmgr.getAttributeValue("MQIA_PLATFORM");
            return isExported(attribute, classId, cmdLevel, platform, node);
        public static boolean isExported(int attribute, String classId, String cmdLevel, String platform,
                                         TopologyModelNode node) {
            String name = ResourceManager.getAttributeName(attribute);
            return isExported(name, classId, cmdLevel, platform, node);
        /** Determine if an attribute is exportable. The attribute name, the classid of the object to
            which it belongs, plus the command level and platform of the queue manager are all needed
            to make this determination.
            Start by finding the AttributeObject for the combination of attribute, classid, and
            command level. If we can't find the AttributeObject, we assume that the attribute
            is not exported. Otherwise, find out if it is exportable for the selected platform.
        public static boolean isExported(String attribute, String classId, String cmdLevel, String platform,
                                         TopologyModelNode node) {
            AttributeObject attr = getAttributeObject(attribute, classId, cmdLevel);
            if (attr == null) {
                return false;
            } else {
                return attr.isExported(platform, node);
        public static boolean isSupported(int attribute, TopologyModelNode node) {
            String name = ResourceManager.getAttributeName(attribute);
            return isSupported(name, node);
        public static boolean isSupported(String attribute, TopologyModelNode node) {
            // Find the qmgr node to fetch platform and cmdlevel
            TopologyModelNode qmgr = node.getModel().getQMgrNode(node.getAddress());
            // If there's no qmgr for this node, it must be one of 'ours'.
            if (qmgr == null)
                return true;
            String classId = node.getClassId();
            String cmdLevel = qmgr.getAttributeValue("MQIA_COMMAND_LEVEL");
            String platform = qmgr.getAttributeValue("MQIA_PLATFORM");
            return isSupported(attribute, classId, cmdLevel, platform);
        public static boolean isSupported(int attribute, String classId, String cmdLevel, String platform) {
            String name = ResourceManager.getAttributeName(attribute);
            return isSupported(name, classId, cmdLevel, platform);
        /** Determine if an attribute is supported. The attribute name, the classid of the object to
            which it belongs, plus the command level and platform of the queue manager are all needed
            to make this determination.
            Start by finding the SupportObject for the classid. If it isn't there, we make the assumption
            (for now) that the attribute is supported. The only classids for which this can occur are
            broker, agent, and the various container objects.
            Propagate the isSupported request to the chain of SupportObjects (based on 'include' values)
            until we get a 'true' result or we run out of SupportObjects. */
        public static boolean isSupported(String attribute, String classId, String cmdLevel, String platform) {
            if (attribute == null)
                return false;
            SupportObject obj = (SupportObject)objects.get(classId);
            // If the object type isn't even in the support matrix, we interpret that to
            // mean that it's a Broker or Agent, in which case all attributes are supported
            // at present.
            if (obj == null)
                return true;
            boolean result = false;
            while (result == false && obj != null) {
                result = obj.isSupported(attribute, cmdLevel, platform);
                if (result == false && obj.getInclude() != null) {
                    obj = (SupportObject)objects.get(obj.getInclude());
                } else
                    obj = null;
            return result;
        /** Locate an AttributeObject for a given attribute name, object type, and command level.
            This is a helper function for the getMaxLen and getType methods. */
        private static AttributeObject getAttributeObject(String attr, String classID, String cmdLevel) {
            AttributeObject result = null;
            SupportObject obj = (SupportObject)objects.get(classID);
            while (result == null && obj != null) {
                result = obj.getAttr(attr, cmdLevel);
                if (result == null && obj.getInclude() != null) {
                    obj = (SupportObject)objects.get(obj.getInclude());
                } else
                    obj = null;
            return result;
        /** Determine the maximum length for a given combintation of attribute name, object type,
            command level, and platform. If the AttributeObject can't be found, or if the length
            hasn't been set, return -1. */
        public static int getMaxLen(String attr, String classId, String cmdLevel, String platform) {
            AttributeObject a = getAttributeObject(attr, classId, cmdLevel);
            if (a == null)
                return -1;
            return a.getMaxLen(platform);
        /** Determine the PCF parm type for a given combintation of attribute name, object type,
            command level, and platform. If the AttributeObject can't be found, or if the length
            hasn't been set, return -1. */
        public static int getType(String attr, String classId, String cmdLevel, String platform) {
            AttributeObject a = getAttributeObject(attr, classId, cmdLevel);
            if (a == null)
                return -1;
            return a.getType(platform);
        /** Inner class to contain platform-specific info for an attribute. */
        class PlatformObject {
            /** This instance variable will contain the comma-delimited string of all
                platforms to which this object applies. */
            private String platform;
            private int maxlen;
            private String condition = null;
            private boolean include;
            private boolean readonly;
            private boolean lenSet;
            private int attrType;
            private boolean typeSet;
            public PlatformObject(String p, boolean readonly) {
                platform = p;
                this.readonly = readonly;
                lenSet = false;
                typeSet = false;
            public PlatformObject(String p) {
                this(p, false);
            public void setCondition(String condition, boolean include) {
                this.condition = condition;
                this.include = include;
            public boolean isReadonly() {
                return readonly;
            public boolean isExported(TopologyModelNode node) {
                if (condition != null) {
                    boolean test = false;
                    try {
                        test = Utilities.evaluateCondition(node, condition);
                    } catch (Exception e) {}
                    if (include ^ test)
                        return false;
                return !readonly;
            public void setLen(int len) {
                maxlen = len;
                lenSet = true;
            public void setType(int type) {
                attrType = type;
                typeSet = true;
            public String getPlatform() {
                return platform;
            public int getMaxLen() {
                if (!lenSet)
                    return -1;
                return maxlen;
            public int getType() {
                if (!typeSet)
                    return -1;
                return attrType;
        /** This class represents a specific MQSeries attribute. It can optionally contain
            instances of the PlatformObject class as needed. When the 'platforms' collection
            is empty, the attribute is supported on all platforms. It is also possible to
            include a PlatformObject for the 'all' platform, if specific attribute characteristics
            need representation. When the 'platforms' collection is non-empty, it will include one
            entry for each platform where the attribute is supported. */
        class AttributeObject {
            private String attribute;
            private String attrValue;
            private HashMap platforms;
            private String condition = null;
            private boolean include;
            private boolean readonly = false;
            public AttributeObject(String a) {
                this(a, false);
            public AttributeObject(String a, boolean readonly) {
                attribute = a;
                platforms = new HashMap();
                this.readonly = readonly;
            public void setCondition(String condition, boolean include) {
                this.condition = condition;
                this.include = include;
            public void setReadonly(boolean readonly) {
                this.readonly = readonly;
            public boolean isReadonly() {
                return readonly;
            public void addPlatform(PlatformObject p) {
                for (StringTokenizer st = new StringTokenizer(p.getPlatform(), ","); st.hasMoreTokens() ;) {
                    platforms.put(st.nextToken(), p);
            public PlatformObject getPlatform(String platform) {
                PlatformObject p = (PlatformObject)platforms.get(platform);
                if (p == null)
                    p = (PlatformObject)platforms.get("all");
                return p;
            public String getAttribute() {
                return attribute;
            public int getMaxLen(String platform) {
                PlatformObject p = getPlatform(platform);
                if (p == null)
                    return -1;
                return p.getMaxLen();
            public int getType(String platform) {
                PlatformObject p = getPlatform(platform);
                if (p == null)
                    return -1;
                return p.getType();
            public boolean isSupported(String platform) {
                if (platforms.isEmpty()) {
                    return true;
                if (platforms.containsKey(platform)) {
                    return true;
                if (platforms.containsKey("all")) {
                    return true;
                return false;
            public boolean isExported(String platform, TopologyModelNode node) {
                if (readonly) {
                    Log.log(Log.DEBUG, this, attribute + " is readonly, returning false");
                    return false;
                if (condition != null) {
                    Log.log(Log.DEBUG, this, "Testing condition = " + condition);
                    boolean test = false;
                    try {
                        test = Utilities.evaluateCondition(node, condition);
                        Log.log(Log.DEBUG, this, "Condition result is " + test);
                    } catch (Exception e) {
                        Log.log(Log.ERROR, this, "Condition through an exception");
                    if (include ^ test)
                        return false;
                if (platforms.isEmpty()) {
                    return true;
                PlatformObject p = getPlatform(platform);
                if (p == null) {
                    Log.log(Log.DEBUG, this, platform + " not found for " + attribute + ", returning false");
                    return false;
                return p.isExported(node);
        /** This class represents a specific value of a queue manager's command level. A
            given instance of this class may 'include' a 'parent' instance through its
            include instance variable. The traversal of the parent/child hierarchy is
            delegated to the SupportObject class, since that is where the collection of
            VersionObjects lives. */
        class VersionObject {
            private String cmdLevel;
            private String include;
            private HashMap attributes;
            public VersionObject(String cmdLevel, String include) {
                this.cmdLevel = cmdLevel;
                this.include = include;
                attributes = new HashMap();
            public void addAttr(AttributeObject attr) {
                attributes.put(attr.getAttribute(), attr);
            public AttributeObject getAttr(String attr) {
                return (AttributeObject)attributes.get(attr);
            public String getCmdLevel() {
                return cmdLevel;
            public String getInclude() {
                return include;
            public boolean isSupported(String attr, String platform) {
                AttributeObject obj = (AttributeObject)attributes.get(attr);
                if (obj == null) {
                    return false;
                } else
                    return obj.isSupported(platform);
        /** This class represents an MQSeries object type, as identified by its classid, e.g.
            queue manager or local queue. This class implements an include facility similar to
            that described for the VersionObject. The traversal of that hierarchy is delegated
            to the static isSupported method, because the collection of SupportObject instances
            is a static variable of the SupportMatrix class. */
        class SupportObject {
            private String classId;
            private String include;
            private HashMap versions;
            public SupportObject(String classId, String include) {
                this.classId = classId;
                this.include = include;
                versions = new HashMap();
            public void addVersion(VersionObject obj) {
                String key = obj.getCmdLevel();
                versions.put(key, obj);
            public String getClassId() {
                return classId;
            public String getInclude() {
                return include;
            public boolean isSupported(String attr, String cmdLevel, String platform) {
                boolean result = false;
                VersionObject obj = (VersionObject)versions.get(cmdLevel);
                if (obj == null)
                    obj = (VersionObject)versions.get("base");
                // I don't actually know what it means if obj is null at this point.
                // It probably can't happen.
                if (obj == null)
                    return false;
                while (result ==  false && obj != null) {
                    result = obj.isSupported(attr, platform);
                    if (result == false && obj.getInclude() != null) {
                        obj = (VersionObject)versions.get(obj.getInclude());
                    } else
                        obj = null;
                return result;
            public AttributeObject getAttr(String attr, String cmdLevel) {
                AttributeObject result = null;
                VersionObject obj = (VersionObject)versions.get(cmdLevel);
                if (obj == null)
                    obj = (VersionObject)versions.get("base");
                // I don't actually know what it means if obj is null at this point.
                // It probably can't happen.
                if (obj == null)
                    return null;
                while (result ==  null && obj != null) {
                    result = obj.getAttr(attr);
                    if (result == null && obj.getInclude() != null)
                        obj = (VersionObject)versions.get(obj.getInclude());
                    else
                        obj = null;
                return result;
    }

    Are you the one who commented out the code you're looking for ?//String desc = StringFactory.getString(attributes.getValue("desc"));You just have to modify you AttributeObject class to hold a new field : String description. And then, it's up to you to create a new constructor or a new setter method.
    Btw, this is not a Swing related question.

Maybe you are looking for

  • Sales Return from Legacy System

    Dear Expert, How to return back stock from sales return where those items were Customer Return that sold using legacy system before  using SAP. Now we need to put back those stock as unrestricted stock, however, we have problem here that we do not ha

  • Questions 'bout setting up auth. for 4 domains: 2 SecurID, 2 PDC

    We have setup a portal with 4 domains. We are currently using one gateway. 2 domains are configured for securID authentication. We'd like to setup the other two domains for authentication using browser certificates. If possible followed by LDAP auth.

  • Entering an accounting vendor to a purch vendor as partner

    Hi Gurus I am having trouble with the following scenario. There is a vendor head office from where purchasing will happen. And they have two regional accounting offices where checks go to. I have created the head office with XK01. I have created the

  • I can not purchase the same apps as my friend purchased using his ID on my ipad

    My ipad was borrowed by my friend, then he signed in to the itunes using his ID and purchased some apps on my ipad. But now i have signed back using my ID in itunes on my ipad. The problem is now using my ipad i can not purchase the same apps that he

  • Installing, a Apple Raid Card

    Hi All I have got my hands on a Apple Raid card (Free), I have checked it all out and it is the correct model for my Mac Pro (early 2009 i believe). now came the fun bit I opend the MP up and installed the card as shown in the instructions (not to ha