Jamisonlucianopatrica's Profile

235
Points

Questions
45

Answers
43

  • Asked on July 17, 2020 in XML.

    After a deeper search, I found the solution. On the second option on the second for loop, you should add the allowing empty function, so that the code ends up looking like this:

    declare option output:method "csv"; declare option output:csv "header=yes, separator=comma";      declare context item := document {<Receipts>     <Receipt>         <Field1 attribute1="a"/>         <Fields2>             <Field2 attribute2="1"/>             <Field2 attribute2="2"/>         </Fields2>         <Field4 attribute4="4a"/>     </Receipt>     <Receipt>         <Field1 attribute1="b"/>         <Field4 attribute4="4b"/>     </Receipt>     <Receipt>         <Field1 attribute1="c"/>         <Fields2>             <Field2 attribute2="3"/>         </Fields2>         <Field3 attribute3="c3"/>         <Field4 attribute4="4c"/>     </Receipt> </Receipts>};    for $x in //Receipt for $y allowing empty in $x/Fields2/Field2 return  <csv>   <record>     <Attribute1>{$x/Field1/@attribute1/data()}</Attribute1>     <Attribute2>{$y/@attribute2/data()}</Attribute2>     <Attribute3>{$x/Field3/@attribute3/data()}</Attribute3>     <Attribute4>{$x/Field4/@attribute4/data()}</Attribute4>   </record> </csv> 

    Which returns the desider CSV:

    Attribute1,Attribute2,Attribute3,Attribute4 a,1,,4a a,2,,4a b,,,4b c,3,c3,4c 
    • 313 views
    • 1 answers
    • 0 votes
  • Asked on July 17, 2020 in XML.

    Try to use :

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"   xmlns:tools="http://schemas.android.com/tools"   android:layout_width="match_parent"   android:layout_height="match_parent"   android:id="@+id/map"   class="com.google.android.gms.maps.SupportMapFragment"/> 

    then in your activity call :

    SupportMapFragment _mapFragment = SupportFragmentManager.FindFragmentById(Resource.Id.map).JavaCast<SupportMapFragment>();          _mapFragment.GetMapAsync(this); 
    • 300 views
    • 4 answers
    • 0 votes
  • Asked on July 17, 2020 in XML.

    As for the DOM manipulation, I think you want

    xmlDoc.insertBefore(result, xmlDoc.documentElement); 

    I don’t think it will help applying the XSLT, however.

    As for the code not working, the following should do:

    const xmlString = `<book>  <title>test<\/title> </book>`;  const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'application/xml'); const result =  xmlDoc.createProcessingInstruction('xml-stylesheet', 'href="test.xsl" type="text/xsl"'); xmlDoc.insertBefore(result, xmlDoc.documentElement);  console.log(new XMLSerializer().serializeToString(xmlDoc));  console.log(xmlDoc);

    To process XSLT and write the result to an iframe it might work to use e.g.

    const xmlString = `<book>  <title>test<\/title> </book>`;  const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'application/xml');  const xslt = `xslt code goes here`;  const xsltDoc = parser.parseFromString(xsltString, 'application/xml');  const xsltProcessor = new XSLTProcessor();  xsltProcessor.importStylesheet(xsltDoc);  const resultDoc = xsltProcessor.transformToDocument(xmlDoc);  const iframeDoc = window.frames.frameName.document;  iframeDoc.open(); iframeDoc.write(new XMLSerializer().serializeToString(resultDoc)); iframeDoc.close(); 
    • 343 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    You can check ButtonTag type inside Where clause using is operator, without mapping to another type in Select method

    var btn = CanvasClock.Children.OfType<Button>().Where(x => x.Tag is ButtonTag buttonTag && buttonTag.IsHour); 
    • 305 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    This is not a perfect solution. I use Material Design components. There are many useful features that are easy to use: https://www.matblazor.com/ and scrolled one of them: https://www.matblazor.com/VirtualScroll

    • 366 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    You can try something like this:

    Select t1.personid, t1.personname, group_concat(t2.purchase_item)  from table1 t1 join table2 t2 on t1.personId = t2.personId  group by personID; 
    • 301 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    DECIMAL(3,1) -> Max is 99.9
    if you want to store 187.5 , change to DECIMAL(4,1) -> Max is 999.9

    • 234 views
    • 1 answers
    • 0 votes
  • show us your code and we’ll try to help you out

    also, if you are indeed imported pygame to you code, remember to add

    import sys  print sys.path 

    to the first three lines and before the import pygame 🙂

    import sys print sys.path import pygame 

    i took this from here.

    • 295 views
    • 5 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    All the __init__ functions need to call super().__init__(), like this:

    class A:     def __init__(self):         super().__init__()         print("in A Init")  class B:     def __init__(self):         super().__init__()         print("in B Init")  class C(B, A):     def __init__(self):         super().__init__()         print("in C Init")  c_obj= C() 

    Per the super() function documentation, it returns a reference to "a parent or sibling" of the class, whichever is next in the method resolution order. At the top of the hierarchy, it returns a reference to the implicit parent class object, which has an empty __init__ method which does nothing.

    In order for this to work well, it’s best for all the inherited __init__ functions to have the same signature, including the common base class; in this case, the signature is just __init__(self) (no additional arguments), and the common base class is object, which also has __init__(self) with no additional arguments, so that’s all good. Another common pattern is for them all to take keyword arguments and pass through **kwargs to the next one.

    • 292 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    Issue – 1:

    it will give me an EOF error because it will split the words in a way that sp.sqrt(4) will be sp.sqrt(4))

    • No, it doesn’t split the string that way because you are splitting the string using ‘ ‘, so the output for the split function will be ['5-(2-sp.sqrt(4))']
    • It won’t give an error unless and until your input has a valid python expression (in this case, I suspect the issue is with sp)

    Issue – 2:

    if I write ‘2-10’ it won’t evaluate it and will just return ‘2-10’ but when I write ‘2-10*(2-5)’ it will return the write answer.

    It is because you have called the eval() function only if there are both ‘(‘ and ‘)’

    Issue – 3:

    It is because eval() takes only valid python expressions ( you can’t put an un-declared variable directly inside the parameter). In your case x was not declared before.

    Solution:

    There is a sympy function parse_expr which probably does what you want here:

    In [20]: from sympy import parse_expr  In [21]: parse_expr('5-(2-sqrt(4))') Out[21]: 5  In [22]: parse_expr('2-10') Out[22]: -8  In [23]: parse_expr('2+x-10-(5*10)') Out[23]: x - 58 
    • 279 views
    • 1 answers
    • 0 votes