How to get Line number from a DOM Element

Hi
I am using dom xerces parser. Is there anyway to work out which line number a element will be when it is outputted into a file ??

org.w3c.dom.DOMLocator method getLineNumber() returns the line number at which an error occurs.
A corrresponding method for file output is not defined.

Similar Messages

  • Line Number of a DOM Element

    Hi There,
    I'm trying to find the originating xml file line number of a DOM element (for purposes of error reporting).
    It seems that you can somehow use the DOMLocator class, however I can't seem to find any explanation of how to do this.
    Please could anyone tell me how?
    Thanks a lot,
    Chris.

    What you're looking to do is validation, and there are multiple ways to do this, already supported by the parsers that come with the JDK. The downside is that writing a grammar that correctly describes your expected XML is not usually trivial.
    There are three common forms of validation: DTD, XSD, and (arguably not common) Relax-NG.
    DTD is the oldest, and is part of the [XML Specification|http://www.xml.com/axml/testaxml.htm]. It allows you to specify the ordering of elements, and the legal attributes for those elements, but not much more.
    XSD, correctly known as [XML Schema|http://www.w3.org/TR/xmlschema-0/], is the W3C-approved validation grammar. The link I gave is to the first of three documents in its spec, and XSD grammars tend to be huge (I know one person who wrote one that was 60 pages long). The benefits of XSD (over DTD) is that it lets you specify min/max counts for elements, union-style groups, and also lets you validate (at some level) the textual content of both elements and attributes.
    [Relax NG|http://relaxng.org/] is meant as a simpler alternative to XSD that retains a similar level of functionality. I've never used it, and haven't had any call to learn it in a professional environment, so can't say much more.
    If you can wait a few weeks, I'm going to put a long article on XML parsing on my website :-) however, assuming you can't wait, here's a chunk of code that shows how you'd do a validating parse with XSD:
    public static void basicSchemaExample()
    throws Exception
        SchemaFactory xsFact = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema xsd = xsFact.newSchema(new StreamSource(new StringReader(xsd)));
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setSchema(xsd);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document dom = db.parse(new InputSource(new StringReader(xml)));
    }

  • How to get Line Number in Purchase Order

    Hi Experts
    I want to get Line Number of Matrix of Purchase Order. How I get it ?
    I want to compare Matrix Line Number with Line Number of POR1 in DB.
    Please Help me.
    Hepil Doshi

    Hi Hepil,
    Linenum in Matrix "38" is Columns.Item("110").Value
    SBO application doesnot show it, but you can get the linenum from that column.
    You can test by getting the column title. omatrix.columns.item("110").Title
    Hope it helps.
    Regards
    Edy

  • How to get week number from date

    Hi,
       please mention how to get the number of week from a particular date using fn module?

    Hi Debarshi,
                       Use FM <b>DATE_GET_WEEK</b>
    Reward points if helpful.
    Regards,
    Hemant

  • How to get a value from the previous element (XSLT/XPATH gurus ahoy!)

    Hi All,
    I am building an RTF template for a "letter of reference"-report. Sometimes there are several rows in the data, that need to be printed as one. This is due to consecutive temporary contracts, which will be printed out as one period of service.
    Here's a simplified data example to illustrate the problem.
    <ROW>
    <START_DATE>01-01-1980</START_DATE>
    <END_DATE>01-01-1988</END_DATE>
    </ROW>
    <ROW>
    <START_DATE>01-01-1988</START_DATE>
    <END_DATE>01-01-1990</END_DATE>
    </ROW>
    <ROW>
    <START_DATE>01-01-2000</START_DATE>
    <END_DATE>01-01-2005</END_DATE>
    </ROW>
    With the data above, I should print two lines:
    01-01-1980 - 01-01-1990
    01-01-2000 - 01-01-2005
    I need to compare START_DATE of an element (except for the first one) with the END_DATE of the previous element, to find out whether to print the END_DATE for that element or not. How can I get that value from the previous element?
    Thanks & Regards, Matilda

    use this to get the following End_date
    <?following-sibling::../END_DATE?>
    Try this
    <?for-each:/ROOT/ROW?>
    ==================
    Current StartDate <?START_DATE?>
    Current End Date <?END_DATE?>
    Next Start Date <?following-sibling::ROW/END_DATE?>
    Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
    ================
    <?end for-each?>
    o/p
    ==================
    Current StartDate 01-01-1980
    Current End Date 01-01-1988
    Next Start Date 01-01-1990
    Previous End Date
    ================
    ==================
    Current StartDate 01-01-1988
    Current End Date 01-01-1990
    Next Start Date 01-01-2005
    Previous End Date 01-01-1988
    ================
    ==================
    Current StartDate 01-01-2000
    Current End Date 01-01-2005
    Next Start Date
    Previous End Date 01

  • How to get page number from the PDF using Javascript

    Hi,
    We are having list of Single page PDF. The pdf are named in the order,
    ISBN_Author_01.PDF  (with real page number as i)
    ISBN_Author_02.PDF  (with real page number as ii)
    ISBN_Author_03.PDF  (with real page number as iii)
    ISBN_Author_04.PDF  (with real page number as 1)
    ISBN_Author_05.PDF  (with real page number as 2)
    ISBN_Author_06.PDF  (with real page number as 3)
    ISBN_Author_nn.PDF  (with real page number as 500)
    Here each pdf has a page number and in sequential order.
    The task is to check whether all the pdfs are in sequential order (i.e i, ii, iii, 1, 2, 3). If any page is missing, the script should throw an error report.
    To do this task, I am writing a Javascript to get the real page number from the PDF.
    Can anybody help me how to get the page number from the PDF using Javascript.
    Thanks,
    Gopal

    The "real" page number within a PDF is the count of the physical page starting at 0, zero.
    pageNum numPages
    The number printed on each page is the page label.
    setPageLabels  getPageLabel
    You will have to open each PDF and your script would need to know the page label for that file. I would expect you would need to build a 2 dimensional  array of the file names and the page label for the page within that array.

  • How to get line number in JAVA code?

    Hi,
    What method can I use to return the current line number of my coding?
    Assuming I'm at line 10 and I want to do something like System.out.println("I am at line number " + ????);What method should I use to get "10"?
    Please advise.
    Thank you.

    If you run Java in Dos prompt, a new line of result is displayed at bottom and the screen scroll. There is no line number in that way. Other language like C have something like that.
    If you use Java Swing, you can display with x, y coordinate option but it is graphic mode.

  • How to get the number from a xml file to flash as3 Text Box "Get_Days"?

    Hi,
    I have to daily update the number of days finished from the specified days. Say, One work to be finished in 30 days. And the start day is today. So, tomorrow it will be 29 days left. and so on....
    So, instead of reducing one number everyday from the last days number using flash, it will be easy changing in xml file.
    How can I do that?
    I have a simple text box "dynamic text box" and the instance name : "Days_Left". Since I am learner, I cannot make complex projects. I am learning small things with very few lines of code which can be modified using xml files.
    So, Whatever I type in a xml file, it should appear in a text box called "Days_Left".
    Thanks.

    then you can use:
    var currentDate:Date = new Date(); 
    // this is today's date
    var projectDueDate:Date = new Date(2010,11,29); 
    // use whatever date you want for the due date.
    // months are zero-based.  (ie, jan is month 0, dec is month 11.)
    var daysToCompleteProject:Number = (projectDueDate.getTime()-currentDate.getTime())/(1000*60*60*24);
    // this is number of days between currentDate and projectDueDate.  you probably want to round or use days:hours:minutes for your display

  • How to get line error from a procedure?

    Hello,
    I want to know the line where the error occurs, since when I treat the exception to show a user friendly error page this erro is not logged at OAS.
    How to do it?
    Thanks in advance.
    EXCEPTION WHEN OTHERS THEN
    HTP.P('Sorry');
    emailme(SQLERRM);
    emailme(line where erro occurs);???????
    END;
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Paula Bronfman ([email protected]):
    Hello,
    I want to know the line where the error occurs, since when I treat the exception to show a user friendly error page this erro is not logged at OAS.
    How to do it?
    Thanks in advance.
    EXCEPTION WHEN OTHERS THEN
    HTP.P('Sorry');
    emailme(SQLERRM);
    emailme(line where erro occurs);???????
    END;
    <HR></BLOCKQUOTE>
    Hi;
    your best bet would be to set a variable in the procedure every 10 lines or so, and email the contents of that var.
    begin
    mydebug:=0;
    mydebug:=10;
    when others then
    emailme(SQLERRM&#0124; &#0124;' '&#0124; &#0124;mydebug);
    end;
    Cheers
    Paulo

  • Need to know how to get imei number from an iphone i no longer have the box, i have the serial number any help!?

    hi i need help if anyone knows how i can find imei number i have the serial number??

    Hey bud sorry i forgot to mention that my phone was stolen, so i go online to see the phone i bought in the apple web page and all i can see is the serial number for the phone, my question is if i can use the serial number to know the imei number?

  • (ABAP-FI)How to get project definition from agiven WBS element

    Hi,
    I have to update some columns of PRPS table relating to a WBS element.
    While using  BAPI_BUS2054_CHANGE_MULTI it wants project definition to be passed as an input parameter.
    Is there any means to know project definition for  a given WBS element of PRPS table.
    Thanks in advance.
    Regards,
    Sourya Prakash.

    Hi,
    why don't you display table PRPS in SE11 to see what fields you have there? It's not that hard to see that there is a field PRPS-PSPHI with description "Current number of the appropriate project". Yes, there is a link from WBS element to project definition.
    Cheers

  • How to get material number in smart form driver prog attached to MM01:NACE?

    Hi,
    I have attached driver program of smart form to MM01 usinfg nace.
    On save smart form should get generated.
    Can anybody guide me how to get material number from MM01 in driver program on saving MM01.
    as of now am not getting values in smart form.
    What additional lines to be coaded in driver program to get material number.
    Thanks.

    hi,
    use nast table in your import paramaters of smart forms.
    In the Nast table you can find a field with object key which holds the Material Number.
    Hope this helps.
    Thanks,
    subash

  • How can we get the selected line number from JTextArea ?

    how can we get the selected line number from JTextArea ? and want to insert line/string given line number into JTextArea??? is it possible ?

    Praitheesh wrote:
    how can we get the selected line number from JTextArea ?
    textArea.getLineOfOffset(textArea.getCaretPosition());
    and want to insert line/string given line number into JTextArea??? is it possible ?
    int lineToInsertAt = 5; // Whatever you want.
    int offs = textArea.getLineStartOffset(lineToInsertAt);
    textArea.insert("Text to insert", offs);

  • How to get Delivery Number at AR-Transaction Lines ?

    Hi,
    We are trying to develop a custom invoice output from AR Transactions (12.0.5). What our aim is to get Delivery Number from Transactions screen at Line Level. We want to provide this, because our client wants to show Delivery Number at this Invoice output...
    How can we provide this ?
    I will be very grateful for any assistance
    Thanks in advance...
    Cagri

    Nagamohan
    First of all i want to thank you for your support.
    we found out that interface_line_attribute3 coloumn is referenced with Waybill field at shipping transactions form. and this field can be seen at Line Transaction Flexfield at AR-Transaction Lines...
    Thanks in advance
    Cagri

  • How to get row number of selected entry from OVS search result

    Hi,
    Anyone having any idea on how to get row number of the  selected entry/ how to differentiate rows in OVS search result in ON_OVS method?
    Regards,
    Jatin

    Hi,
    You can get the selected record to <ls_selection> structure in co phase 3.
    From that structure you can get what ever field you want.,
    check the below code for reference,
    << Moderator message - Cut and paste response from F4 help for ALV table field removed. Plagiarism is not allowed in SCN >>
    hope this helps u.,
    Thanks & Regards,
    Kiran
    Edited by: Rob Burbank on Jan 5, 2012 5:24 PM

Maybe you are looking for