Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8209247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:39:27+00:00 2026-06-07T09:39:27+00:00

I run into strange problem and I cant find anything on web for that.

  • 0

I run into strange problem and I cant find anything on web for that.

Im using xpath to locate my xml chunk and then replace it with something else ex:

// input
<html>
    ...
    <style type="">
        background: yellow;
    </style> 
    <link href="path" /> 
</html>


// output
<html>
    ...
    <link href="pathToFileWithBackground" />
    <link href="path_other" /> 
</html>

I use XMLModifier to actually update token (using updateToken method :]) and it works for attributes manipulation or for text (body) of element.

I have problem with style element, I want to process its body and then replace whole element with link to some file.

obviously updating text token will result with style token with link tag inside it.

    <style type=""><link href="path" />
    </style>

so I tried moving navigator to style element and got this

    <<link href="path" /> type="">
        background: yellow;
    </style> 

I also tried inserting link element before style element and removing it but I got ModifyException(“Invalid insertion/deletion condition detected between offset .. and offset”) from XMLModifier when I try to save modifier’s data. here is the code for that

      ap.selectXPath("//style/text());
      vn.toElement(VTDNav.PARENT);                  
      modifier.insertBeforeElement(replaceString);  
      modifier.remove();                                                

I tried to use remove(long l) and remove(int offset, int lengtt) version but got same exception

any ideas on that

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:39:29+00:00Added an answer on June 7, 2026 at 9:39 am

    OK so the problem was with

    vn.getElementFragment()
    

    returned wrong length. maybe because (in my test file) style element was followed by comments and comment characters were included and length was bigger than it should be

    this fixed everything

    int o = (int)vn.getElementFragment();
    int l = (int)(vn.getElementFragment() >> 32);
    final String s = new String(vn.getXML().getBytes(o, l));
    l = s.substring(0, s.indexOf("</style>")+8).length(); // ;]
    modifier.removeContent(o, l);
    modifier.insertBeforeElement(replaceString);
    

    hope it will help someone

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a strange problem on Android , using jQuery mobile and
I've run into a strange problem with Ruby that I can't explain. I have
I've run into a rather strange problem. I have a div that is rotatable
I've run into a strange problem that I am having difficulty tracking down. I
I have run into a strange problem, i am creating a lot of dynamically
I seemed to have run into a strange problem with the CCParticleSystem and the
I run into follow problem. Did I miss anything? Association.all().count() 1 Association.all().fetch(1) [Association(**{'server_url': u'server-url',
I run into an interesting problem while was using combos in input form. My
I've run into a strange problem regarding default buttons in master pages and IIS7
I've run into a strange problem while writing some code for my personal use.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.