Kennithkarenthelma's Profile

200
Points

Questions
39

Answers
43

  • Asked on July 17, 2020 in XML.

    Following your code for the header row, you could achieve this by an

    <xsl:apply-templates select="/report/order_actions/order_action[order_id = current()/order_id]" />

    As well as a template to create the order action rows:

    <xsl:template match="order_action" > <tr> ....your code here </tr> </xsl:template> 

    The select on apply-templates filters the node-set of order_actions to those which match the order by id before invoking the template. The second template runs once per order_action in this node-set.

    You may also want to sort them by the date they occurred, assuming they don’t necessarily appear in the document in date order. In which case, add an

    <xsl:sort select="order_action_dt" order="descending" />

    inside the apply-templates.

    edit:

    I mistakenly used the shorthand for the context node . and not the current node current() – where the context node changes inside an XPath selector because it is evaluating a node-set and each one in turn becomes the context node. The current node is the node currently in scope for the template. Replacing ./order_id for current()/order_id should get you what you want.

    • 1177 views
    • 1 answers
    • 0 votes
  • Asked on July 17, 2020 in XML.

    Not sure if there was another way of doing this, but I fixed the prefix by creating a namespace mapper:

    public class DefaultNamespacePrefixMapper extends NamespacePrefixMapper {      private Map<String, String> namespaceMap = new HashMap<>();      /**      * Create mappings.      */     public DefaultNamespacePrefixMapper() {         namespaceMap.put("http://www.sitemaps.org/schemas/sitemap/0.9", "");         namespaceMap.put("http://www.google.com/schemas/sitemap-image/1.1", "image");     }      @Override     public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {         return namespaceMap.getOrDefault(namespaceUri, suggestion);     } } 

    And when using the marshaller, I simply set:

    Marshaller m = context.createMarshaller(); DefaultNamespacePrefixMapper mapper = new DefaultNamespacePrefixMapper(); m.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", mapper); 

    My XML looks correct exactly the same way as google documentation.

    • 283 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in XML.

    In your child linear layout add margin using the following syntax:

    android:layout_margin="24dp" 

    You should replace the margin dp value with your own value so that it gives the desired result.

    • 273 views
    • 3 answers
    • 0 votes
  • Another general case where one might receive this exception involves mocking classes during unit testing. Regardless of the mocking framework being used, you must ensure that all appropriate levels of the class hierarchy are properly mocked. In particular, all properties of HttpContext which are referenced by the code under test must be mocked.

    See “NullReferenceException thrown when testing custom AuthorizationAttribute” for a somewhat verbose example.

    • 844 views
    • 28 answers
    • 0 votes
  • Simply use a UNION function with NOT IN on the second part like this:

    SELECT * FROM table1 WHERE id IN(list_of_ids) UNION SELECT * FROM table1 WHERE id NOT IN(list_of_ids); 

    I hope this is what you want.

    • 280 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    I can recommend for different approach for this, pass PIPEs to the stderr and stdout for the spawned process and check those pipes after child return.

    import subprocess outs=None errs=None  try:     proc=subprocess.Popen(["pdftotext -v"], shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)     outs, errs = proc.communicate(timeout=15)  #timing out the execution, just if you want, you dont have to! except TimeoutExpired:     proc.kill()     outs, errs = proc.communicate()  #parse the stderr and stdoutput of proc: f_check_if_has_errors(errs, outs) 

    Also consider to use/look subprocess.check_call method below:

    try:   proc = subprocess.check_call(["pdftotext -v"], shell=True)   proc.communicate() except subprocess.CalledProcessError:   # There was an error - command exited with non-zero code 
    • 284 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    Python containers contain references to other objects. See this example:

    >>> a = [] >>> b = [a] >>> b [[]] >>> a.append(1) >>> b [[1]] 

    In this b is a list that contains one item that is a reference to list a. The list a is mutable.

    The multiplication of a list by an integer is equivalent to adding the list to itself multiple times (see common sequence operations). So continuing with the example:

    >>> c = b + b >>> c [[1], [1]] >>> >>> a[0] = 2 >>> c [[2], [2]] 

    We can see that the list c now contains two references to list a which is equivalent to c = b * 2.

    Python FAQ also contains explanation of this behavior: How do I create a multidimensional list?

    • 570 views
    • 14 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    You can’t do this. What you can do is change the item object to a dictionary instead.

    Then you can look up the dictionary value in the template

    • 319 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in HTML.

    The drop down menu may still be there, just hidden. Try pressing f12 while on the page, your dev tools should pop up. If your on Chrome look for the tab that says ‘Elements’ to view the computed source code of the web page. Firefox also has a builtin dev tools. Its’ options should be pretty self explanatory, but here I’ll cover Chromes’.

    All the way to the left you’ll find an arrow in a box. Click it to sync the source view with the page elements so as you move your mouse over the page it shows the code in the ‘Elements’ window. Move the mouse over the menu to see it’s code.

    However the menu, most likely, will not drop down while in this mode when you hover. You will have to investigate the source after clicking on the element you want to view, you can dynamically change it’s css (or html). Your changes will remain until you refresh the page. Instead of having selenium ‘hover’, just grab the element you want like so: driver.findElement(By.tagName("div")). The Seleniums’ documentation can be found here: https://www.selenium.dev/documentation/en/webdriver/web_element/

    Grab the href value of the duh tags if you just need to follow the link. But if you need to click the link try this: driver.findElement(By.linkText("See an example alert")).click();

    In this case you would just have too know the text between the TEXT tags. If this doesn’t work try making the menu visible using selenium before clicking. To make it visible look through the source to see if display is none on the menu. If it is then make it something like block or inline then try again.

    If you still have problems poke around in the ‘Sources’ tab in dev tools. You can search for element tags in the javascript, and there’s also a debug function to step through the code to see what javascript is doing when you hover. You basically just need to make the element visible to selenium before you click, that is if the previous solutions don’t work. Hope this helps.

    • 255 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in HTML.

    You are trying to add event listeners to HTML nodes which are not created at particular instance.

    In order to solve this issue try re-ordering your code slightly. Call function "createModeOptions" before adding the event listeners and it will work as expected.

    • 238 views
    • 1 answers
    • 0 votes