问:
Is mod_rewrite a valid option for caching dynamic pages with Apache?
I have read about a technique involving writing to disk a rendered dynamic page and using that when it exists using mod_rewrite. I was thinking about cleaning out the cached version every X minutes using a cron job.

I was wondering if this was a viable option or if there were better alternatives that I am not aware of.

(Note that I'm on a shared machine and mod_cache is not an option.)

答:
Does the page need to be junked every so often because it just has to? Or should it be paralleled with a static version after an update to the page?

If the latter, you could try and write a script that would make a copy of the just edited page and save it to its static filename version. That should lighten the write load since in that scenario you wouldn't need to have a fresh static copy unless there was a change made that needed some show time.

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Random Echo


来源: stackexchange

问:
Avoid generating codes for object's property
I use DefaultValue for a property so that it will be not generated in designer when I create a control which has this property in designer. However, with properties which have data type is not standard, example: Image, how to use DefaultValue. Thanks.

This is an example codes:

```<code>using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace DemoChart
{
  public class MyControl : Control
  {
    private Image m_Img = DemoChart.Properties.Resources.link;

    [DefaultValue("DemoChart.Properties.Resources.link")]
    public Image Img
    {
      get { return m_Img; }
      set { m_Img = value; }
    }

    public MyControl()
    {
    }
  }
}
</code>```

Note: DemoChart.Properties.Resources.link is a Image resource which I add in project.

I create a form named Form1, drag a MyControl to this form and it name is myControl1. I open Form1.designer.cs to view generated codes, I still see myControl1's Img property. Why? I use DefaultValue but it doesn't have effect. Please help me. Thanks.

答: If your property has a complex data type then you are supposed to use the ShouldSerialize and Reset methods.

ContentLicense: CC BY-SA 3.0

Body:
I use DefaultValue for a property so that it will be not generated in designer when I create a control which has this property in designer. However, with properties which have data type is not standard, example: Image, how to use DefaultValue. Thanks.

This is an example codes:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.ComponentModel;

namespace DemoChart
{
  public class MyControl : Control
  {
    private Image m_Img = DemoChart.Properties.Resources.link;

    [DefaultValue("DemoChart.Properties.Resources.link")]
    public Image Img
    {
      get { return m_Img; }
      set { m_Img = value; }
    }

    public MyControl()
    {
    }
  }
}

Note: DemoChart.Properties.Resources.link is a Image resource which I add in project.

I create a form named Form1, drag a MyControl to this form and it name is myControl1. I open Form1.designer.cs to view generated codes, I still see myControl1's Img property. Why? I use DefaultValue but it doesn't have effect. Please help me. Thanks.


问:
What is the best method to sort a dynamic array of c-strings in a class in c++?
In my current programming class I've been tasked with creating a program that takes user input course (Consisting of course name, course grade, course units variables) and storing them in a dynamically generated array with a maximum size of 10.

Due to my unfamiliarity with object oriented programming and classes however I'm finding anything beyond the pure creation of the classes to be very difficult. I've figured out a way to create the entries, as well as how to edit them after they've been created using friend functions (I think that's the name?) stored in my programs header file.

However now that I've needed to perform a sort on the data (by the name variable of every entry) as well as to then search it I'm finding it very difficult to proceed. I understand how to make functions that can do both of these things (As I have done it for my previous class), but doing it with classes being involved is proving challenging.

My header file:

```<code>#ifndef COURSE_H
#define COURSE_H

#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include <vector>

class Course
{
private:
    char name[10] = ""; //name of course
    char grade; //grade in course
    int units; //units in course

public:
    Course()
    {
        name;
        grade;
        units;
    }

    void read() //Initializes course and collects information from user
    {
        std::cout << "\nEnter course name: ";
        std::cin.getline(name, 10, '\n');
        std::cout << "\nEnter number of units: ";
        std::cin >> units;
        std::cout << "\nEnter grade received: ";
        std::cin >> grade;
        std::cin.ignore();
    }

    void display() const //Displays course to user
    {
        std::cout << name << ' ' << units << ' ' << grade << std::endl;
    }

    ~Course() //Destructor frees allocated dynamic memory
    {
        std::cout << "\nDeleting any dynamically created object";
    }
};

#endif // COURSE_H
</code>```

My main source file:

```<code>#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include <vector>
#include "courses.h"

int menu();
void add(Course* co_ptr[], int& size);
void edit(Course* co_ptr[], int size);
void swap_ptrs(Course*& pt1, Course*& pt2);

int main()
{
    Course* courses[10] = {};
    int selection;

    int size = 0;
    do
    {
        selection = menu();

        if (selection == 1)
        {
            if (size < 10)
                add(courses, size);
            else
                std::cout << "\nUnable to add more classes.";
        }
        else if (selection == 2)
        {
            edit(courses, size);
        }
        else if (selection == 3)
        {

        }
        else if (selection == 4)
        {

        }
        else if (selection == 5)
        {

        }
        else if (selection == 6)
        {

        }
        else if (selection == 7)
        {
            break;
        }
        else
        {
            std::cout << "\nInvalid selection.";
        }
    } while (selection != 7);

    std::cout << "\nPress any key to exit.";
    (void)_getch();
    return 0;
}
</code>```

My functions source file:

```<code>#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include <vector>
#include "courses.h"

int menu()
{
    int selection;

    std::cout << "\nSelect one of the following actions: " << std::endl
        << "1. Add new course" << std::endl
        << "2. Edit an existing course" << std::endl
        << "3. Display a course" << std::endl
        << "4. List all courses" << std::endl
        << "5. Display GPA" << std::endl
        << "6. Delete all courses" << std::endl
        << "7. Quit";
    std::cout << "\nEnter selection number: ";
    std::cin >> selection;
    std::cin.ignore();

    return selection;
}

void add(Course* co_ptr[], int& size)
{
    co_ptr[size] = new Course;
    co_ptr[size]->read();
    size++;
}

void edit(Course* co_ptr[], int size)
{
    int selection;
    for (int i = 0; i < size; i++)
    {
        std::cout << std::endl << i << ". ";
        co_ptr[i]->display();
    }

    std::cout << "Enter your selection: ";
    std::cin >> selection;
    std::cin.ignore();

    co_ptr[selection]->read();
}
</code>```

My last attempt at making a sort function (I tried to create it within the header as whenever I ported in my old sorting code as a normal function it couldn't access the data it needed on account of those variables being "private")

```<code>void Course::sort_name(Course* co_ptr[], int size) //has to be apart of the class (Course::) to have access to the name data
{
    bool swap;

    do
    {
        swap = false;
        for (int i = 0; i < size - 1; i++)
        {
            if (strcmp(co_ptr[i]->name, co_ptr[i + 1]->name) > 0) //We're now comparing and swapping pointers
            {
                swap_ptrs(co_ptr[i], co_ptr[i + 1]);
                swap = true;
            }
        }
    } while (swap);
}
</code>```

Lastly my swap_ptrs function which was also in the function source file:

```<code>void swap_ptrs(Course*& pt1, Course*& pt2) //Passes the pointers by reference
{
    Course* tmp = pt1;
    pt1 = pt2;
    pt2 = tmp;
}
</code>```

I'm sorry for such a long post but this project has been a real struggle and I'm feeling like I'm not making any headway.

答:
You could use a container like std::list or std::vector to store your Course-Objects instead of an array and the use  std::sort with a comparison-method of your choosing. That would probably be the easiest. If you have to stick to arrays as container, you could also use sort like this:

```<code>std::sort(array, array + array_size,[](Course* a, Course* b) {
        return strcmp(a->name, b->name) < 0;
    });
</code>```

But that is more like C than C++
...

ContentLicense: CC BY-SA 4.0

Body:
In my current programming class I've been tasked with creating a program that takes user input course (Consisting of course name, course grade, course units variables) and storing them in a dynamically generated array with a maximum size of 10.

Due to my unfamiliarity with object oriented programming and classes however I'm finding anything beyond the pure creation of the classes to be very difficult. I've figured out a way to create the entries, as well as how to edit them after they've been created using friend functions (I think that's the name?) stored in my programs header file.

However now that I've needed to perform a sort on the data (by the name variable of every entry) as well as to then search it I'm finding it very difficult to proceed. I understand how to make functions that can do both of these things (As I have done it for my previous class), but doing it with classes being involved is proving challenging.

My header file:

#ifndef COURSE_H
#define COURSE_H

#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include <vector>

class Course
{
private:
    char name[10] = ""; //name of course
    char grade; //grade in course
    int units; //units in course

public:
    Course()
    {
        name;
        grade;
        units;
    }

    void read() //Initializes course and collects information from user
    {
        std::cout << "\nEnter course name: ";
        std::cin.getline(name, 10, '\n');
        std::cout << "\nEnter number of units: ";
        std::cin >> units;
        std::cout << "\nEnter grade received: ";
        std::cin >> grade;
        std::cin.ignore();
    }

    void display() const //Displays course to user
    {
        std::cout << name << ' ' << units << ' ' << grade << std::endl;
    }

    ~Course() //Destructor frees allocated dynamic memory
    {
        std::cout << "\nDeleting any dynamically created object";
    }
};

#endif // COURSE_H

My main source file:

#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include <vector>
#include "courses.h"

int menu();
void add(Course* co_ptr[], int& size);
void edit(Course* co_ptr[], int size);
void swap_ptrs(Course*& pt1, Course*& pt2);

int main()
{
    Course* courses[10] = {};
    int selection;

    int size = 0;
    do
    {
        selection = menu();

        if (selection == 1)
        {
            if (size < 10)
                add(courses, size);
            else
                std::cout << "\nUnable to add more classes.";
        }
        else if (selection == 2)
        {
            edit(courses, size);
        }
        else if (selection == 3)
        {

        }
        else if (selection == 4)
        {

        }
        else if (selection == 5)
        {

        }
        else if (selection == 6)
        {

        }
        else if (selection == 7)
        {
            break;
        }
        else
        {
            std::cout << "\nInvalid selection.";
        }
    } while (selection != 7);

    std::cout << "\nPress any key to exit.";
    (void)_getch();
    return 0;
}

My functions source file:

#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <cstdlib>
#include <vector>
#include "courses.h"

int menu()
{
    int selection;

    std::cout << "\nSelect one of the following actions: " << std::endl
        << "1. Add new course" << std::endl
        << "2. Edit an existing course" << std::endl
        << "3. Display a course" << std::endl
        << "4. List all courses" << std::endl
        << "5. Display GPA" << std::endl
        << "6. Delete all courses" << std::endl
        << "7. Quit";
    std::cout << "\nEnter selection number: ";
    std::cin >> selection;
    std::cin.ignore();

    return selection;
}

void add(Course* co_ptr[], int& size)
{
    co_ptr[size] = new Course;
    co_ptr[size]->read();
    size++;
}

void edit(Course* co_ptr[], int size)
{
    int selection;
    for (int i = 0; i < size; i++)
    {
        std::cout << std::endl << i << ". ";
        co_ptr[i]->display();
    }

    std::cout << "Enter your selection: ";
    std::cin >> selection;
    std::cin.ignore();

    co_ptr[selection]->read();
}

My last attempt at making a sort function (I tried to create it within the header as whenever I ported in my old sorting code as a normal function it couldn't access the data it needed on account of those variables being "private")

void Course::sort_name(Course* co_ptr[], int size) //has to be apart of the class (Course::) to have access to the name data
{
    bool swap;

    do
    {
        swap = false;
        for (int i = 0; i < size - 1; i++)
        {
            if (strcmp(co_ptr[i]->name, co_ptr[i + 1]->name) > 0) //We're now comparing and swapping pointers
            {
                swap_ptrs(co_ptr[i], co_ptr[i + 1]);
                swap = true;
            }
        }
    } while (swap);
}

Lastly my swap_ptrs function which was also in the function source file:

void swap_ptrs(Course*& pt1, Course*& pt2) //Passes the pointers by reference
{
    Course* tmp = pt1;
    pt1 = pt2;
    pt2 = tmp;
}

I'm sorry for such a long post but this project has been a real struggle and I'm feeling like I'm not making any headway.

Body:
You could use a container like std::list or std::vector to store your Course-Objects instead of an array and the use  std::sort with a comparison-method of your choosing. That would probably be the easiest. If you have to stick to arrays as container, you could also use sort like this:

std::sort(array, array + array_size,[](Course* a, Course* b) {
        return strcmp(a->name, b->name) < 0;
    });

But that is more like C than C++
...


问:
How to save jtable to excel including headers using poi?
How can I get the JTable header to save in excel i have a code that only the values are saved but header is not including im using POI 3.14 heres my code</p>

```<code>for (int i = 0; i <  model.getRowCount(); i++) {
  XSSFRow excelRow = excelSheet.createRow(i);
   for (int j = 0; j <  model.getColumnCount(); j++) {
     XSSFCell excelCell = excelRow.createCell(j);
     excelCell.setCellValue(model.getValueAt(i, j).toString());
     }
 }
</code>```

答:
i got my solution thanks</p>

```<code>` for (int i = 0; i <  model.getRowCount()+1; i++) {
      SSFRow excelRow = excelSheet.createRow(i);
      for (int j = 0; j <  model.getColumnCount(); j++) {
          if(i == 0){
                XSSFCell excelCell = excelRow.createCell(j);
                excelCell.setCellValue(model.getColumnName(j));
           }else{
                 XSSFCell excelCell = excelRow.createCell(j);
                 excelCell.setCellValue(model.getValueAt(i-1, j).toString());
                 }
        }
  }`
</code>```

Body:
How can I get the JTable header to save in excel i have a code that only the values are saved but header is not including im using POI 3.14 heres my code

for (int i = 0; i <  model.getRowCount(); i++) {
  XSSFRow excelRow = excelSheet.createRow(i);
   for (int j = 0; j <  model.getColumnCount(); j++) {
     XSSFCell excelCell = excelRow.createCell(j);
     excelCell.setCellValue(model.getValueAt(i, j).toString());
     }
 }

Body:
i got my solution thanks

` for (int i = 0; i <  model.getRowCount()+1; i++) {
      SSFRow excelRow = excelSheet.createRow(i);
      for (int j = 0; j <  model.getColumnCount(); j++) {
          if(i == 0){
                XSSFCell excelCell = excelRow.createCell(j);
                excelCell.setCellValue(model.getColumnName(j));
           }else{
                 XSSFCell excelCell = excelRow.createCell(j);
                 excelCell.setCellValue(model.getValueAt(i-1, j).toString());
                 }
        }
  }`


问:
How to make two android devices to communicate through TCP
We want to establish TCP/IP connection between two android devices.
For now we thought that it would be simpler if we make the connection device to device. So there is no server that is between the two phones.

Most of the time (if not always) one has no real IP address (NAT and so on). Is this a problem for creating a TCP socket?
I didn't manage to find any exact information for this. Any advice and opinion will be highly appreciated.

Thanks

答:
Is this a problem for creating a TCP
  socket?

Answer is no, it does not make it impossible (unless NAT's have an unpredictable way of mapping IP addresses). However, it is not simple to accomplish.

The short answer is you'll always need a server-like peer with a public IP address to facilitate initial communication between peers located behind NATs. The peers connect to it. A tells server it wants to TCP connect with B. Server notifies B. NAT behavior analysis is performed and if possible, A and B attempt to open TCP communications with each other by predicting the next mapping of the other NAT. If all goes fine (and usually it does) A touches base with B or vice-versa. They close the other connection attempts and communicate with the operational TCP connection. This technique is called STUN for TCP.

Now, there are more complicated reason why things can go wrong. If you want to know more, I have written a book called Practical JXTA II which available for reading online at Scribd. There is a chapter dedicated to NAT traversal.

Hope this helps.


问:
while loop with store value for next while loop in java
I'm a beginner in Java. I have an assignment that require me to take 3 input from user, then output the 3 at the same time.
here is my code. i have only get 1 output.
suppose look like this:

anyone could help, thx!

here is my code

```<code>Scanner sc = new Scanner(System.in);

  int i = 0;
  String classname = " ";
  String rating = " ";
  int plus = 0;

  while(i < 3){
    System.out.print("What class are you rating? ");
    classname = sc.nextLine();

    System.out.print("How many plus signs does " + classname +" get? ");
    rating = sc.nextLine();
    plus = Integer.parseInt(rating);

    i++;
  }
    System.out.print(classname + ": ");

    while (plus > 0){
      System.out.print("+");
      plus --;
    }
    System.out.println();
</code>```

答:
You overwrite your variables classname and rating in each loop. You need to store each iteration in a field of an array.</p>

```<code>Scanner sc = new Scanner(System.in);

  int i = 0;
  String[] classname = new String[3]; //create array
  String rating = " "; //rating can be overwritten, it is not needed after the loop
  int[] plus = new int[3];

  while(i < 3){
    System.out.print("What class are you rating? ");
    classname[i] = sc.nextLine(); //name[index] to read/write fields of an array
                                  //index starts at 0

    System.out.print("How many plus signs does " + classname +" get? ");
    rating = sc.nextLine();
    plus[i] = Integer.parseInt(rating);

    i++;
  }
for(i = 0;i<3;i++){ //iterate over all elements in the array
    System.out.print(classname[i] + ": ");

    while (plus[i] > 0){
      System.out.print("+");
      plus[i] --;
    }
    System.out.println();
}

</code>```

Body:
I'm a beginner in Java. I have an assignment that require me to take 3 input from user, then output the 3 at the same time.
here is my code. i have only get 1 output.
suppose look like this:

anyone could help, thx!

here is my code

Scanner sc = new Scanner(System.in);

  int i = 0;
  String classname = " ";
  String rating = " ";
  int plus = 0;

  while(i < 3){
    System.out.print("What class are you rating? ");
    classname = sc.nextLine();

    System.out.print("How many plus signs does " + classname +" get? ");
    rating = sc.nextLine();
    plus = Integer.parseInt(rating);

    i++;
  }
    System.out.print(classname + ": ");

    while (plus > 0){
      System.out.print("+");
      plus --;
    }
    System.out.println();

Body:
You overwrite your variables classname and rating in each loop. You need to store each iteration in a field of an array.

Scanner sc = new Scanner(System.in);

  int i = 0;
  String[] classname = new String[3]; //create array
  String rating = " "; //rating can be overwritten, it is not needed after the loop
  int[] plus = new int[3];

  while(i < 3){
    System.out.print("What class are you rating? ");
    classname[i] = sc.nextLine(); //name[index] to read/write fields of an array
                                  //index starts at 0

    System.out.print("How many plus signs does " + classname +" get? ");
    rating = sc.nextLine();
    plus[i] = Integer.parseInt(rating);

    i++;
  }
for(i = 0;i<3;i++){ //iterate over all elements in the array
    System.out.print(classname[i] + ": ");

    while (plus[i] > 0){
      System.out.print("+");
      plus[i] --;
    }
    System.out.println();
}


问:
How to add Ajax response to div in html
How to append Ajax response to div in HTML

This is my ajax Code

```<code>$(document).ready(function(){
    $('.credit,.debit').change(function(){
        var value=$(this).val();
        $.ajax({
            type:"POST",
            url:"<?php echo base_url();>index.php/Transactions/getamountbyid",
            data:{id:value},
            success:function(result){
                console.log(result);
                $(".bal").html(result);
            }
        });
    });
});
</code>```

This is my controller Code

```<code>public function getamountbyid(){
    $id=$this->input->post('id');
    $this->Transaction_model->getamountbyid($id);
    print_r($data1);
}
</code>```

And THIS is my Ajax Response

```<code>Array ( [0] => stdClass Object ( [Accounts_id] => 1 [Accounts_number] => 123123123 [Account_Name] => Qualight [account_nickname] => Qualight [Address] => hyderabad [Mobile] => 9123912345 [account_type] => 1 [PAN_NO] => 1231231231 [GST_NO] => 123 [credit] => 20000.00 [debit] => [balance] => 20000.00 [Time_stamp] => 2020-02-13 18:51:49 ) )
</code>```

I want to display account debit and credit balance after selecting the account from drop down it should be display below drop down can you please help me how to append required response data to required field or div

答:
First off, change print_r($data1); to return json_encode($data1); if return doesn't work then try echo.
Next, change $(".bal").html(result); to $(".bal").html( result[0].credit+"
"+result[0].debit);

Title: How to add Ajax response to div in html

Body:
How to append Ajax response to div in HTML

This is my ajax Code

$(document).ready(function(){
    $('.credit,.debit').change(function(){
        var value=$(this).val();
        $.ajax({
            type:"POST",
            url:"<?php echo base_url();>index.php/Transactions/getamountbyid",
            data:{id:value},
            success:function(result){
                console.log(result);
                $(".bal").html(result);
            }
        });
    });
});

This is my controller Code

public function getamountbyid(){
    $id=$this->input->post('id');
    $this->Transaction_model->getamountbyid($id);
    print_r($data1);
}

And THIS is my Ajax Response

Array ( [0] => stdClass Object ( [Accounts_id] => 1 [Accounts_number] => 123123123 [Account_Name] => Qualight [account_nickname] => Qualight [Address] => hyderabad [Mobile] => 9123912345 [account_type] => 1 [PAN_NO] => 1231231231 [GST_NO] => 123 [credit] => 20000.00 [debit] => [balance] => 20000.00 [Time_stamp] => 2020-02-13 18:51:49 ) )

I want to display account debit and credit balance after selecting the account from drop down it should be display below drop down can you please help me how to append required response data to required field or div

Body:
First off, change print_r($data1); to return json_encode($data1); if return doesn't work then try echo.
Next, change $(".bal").html(result); to $(".bal").html( result[0].credit+"<br>"+result[0].debit);


问:
how to change title for only "checkout" in wocommerce wordpress website
I don't know how to change checkout text. Please help me out to give me function.php code I will use to my website.

答:
CHANGE CHECKOUT TEXT

Open function.php theme file using FPT or admin theme editor

Add the following code at the bottom of function.php file & Save the changes

```<code><?php function woocommerce_button_proceed_to_checkout() {
$checkout_url = WC()->cart->get_checkout_url(); ?>
<a href="<?php echo esc_url( wc_get_checkout_url() );?>" class="checkout-button button alt wc-forward"> <?php esc_html_e( 'Secure Checkout', 'woocommerce' ); ?>
</a> <?php } ?>
</code>```

Body:
CHANGE CHECKOUT TEXT

Open function.php theme file using FPT or admin theme editor

Add the following code at the bottom of function.php file & Save the changes

<?php function woocommerce_button_proceed_to_checkout() {
$checkout_url = WC()->cart->get_checkout_url(); ?>
<a href="<?php echo esc_url( wc_get_checkout_url() );?>" class="checkout-button button alt wc-forward"> <?php esc_html_e( 'Secure Checkout', 'woocommerce' ); ?>
</a> <?php } ?>


答:
You need to create a div with identifier where you want to show the credit/debit and populate this div with in ajax response.

Firstly, use json_encode()

```<code>public function getamountbyid(){
         $id=$this->input->post('id');
$this->Transaction_model->getamountbyid($id);
**print_r(json_encode($data1));**
    }
</code>```

Then, use

```<code>$("#target-div").append(JSON.stringify(data));

success: function (data) {
            for(var key in data) {
            var value = data[key];
                html+='<div>'+key+':'+value+'</div>'
            }
            $("#target-div").append(html);
</code>```

Title: How to add Ajax response to div in html

Body:
You need to create a div with identifier where you want to show the credit/debit and populate this div with in ajax response.

Firstly, use json_encode()

public function getamountbyid(){
         $id=$this->input->post('id');
$this->Transaction_model->getamountbyid($id);
**print_r(json_encode($data1));**
    }

Then, use

$("#target-div").append(JSON.stringify(data));

success: function (data) {
            for(var key in data) {
            var value = data[key];
                html+='<div>'+key+':'+value+'</div>'
            }
            $("#target-div").append(html);


问:
How to assign values in an Angular form without an input element or hiding the UI element?
I am working on this template-driven form, where I have a dropdown.

The dropdown has an ID as value and Name as the display value.

When I submit the form, I need both the values ID and Name to be in the form output

```<code>   <mat-form-field>
            <mat-label>State</mat-label>
            <mat-select [(ngModel)]="data.stateCode" name="StateCode" #yddfyty>
              <mat-option *ngFor="let state of stateOptions" [value]="state.ID">
                {{state.name}}
              </mat-option>
            </mat-select>
   </mat-form-field>
</code>```

After submitting the form, I get a JSON

```<code>{
  StateCode: "Option I select in the Dropdown"
}
</code>```

When I submit the form, I also want the StateName to be in the form output.

How do I assign the StateName selected in the Dropdown, to a model property in the template-driven form?

I can think of a way where we can use an  element and hide the element, Is there any other way?

Is the only way to do it in the Typescript file after submitting?

答: Yes, with the given restrictions you will have to handle the form submit in .ts file.

Body:
I am working on this template-driven form, where I have a dropdown.

The dropdown has an ID as value and Name as the display value.

When I submit the form, I need both the values ID and Name to be in the form output

   <mat-form-field>
            <mat-label>State</mat-label>
            <mat-select [(ngModel)]="data.stateCode" name="StateCode" #yddfyty>
              <mat-option *ngFor="let state of stateOptions" [value]="state.ID">
                {{state.name}}
              </mat-option>
            </mat-select>
   </mat-form-field>

After submitting the form, I get a JSON

{
  StateCode: "Option I select in the Dropdown"
}

When I submit the form, I also want the StateName to be in the form output.

How do I assign the StateName selected in the Dropdown, to a model property in the template-driven form?

I can think of a way where we can use an  element and hide the element, Is there any other way?

Is the only way to do it in the Typescript file after submitting?


问:
Where can I download the Saxon validate example?
[In this question][1] it was recommended I look at the Saxon EE validate example. Where can I download it? It's not in [this] [2] or [this] [3].</p>

```<code>  [1]: https://stackoverflow.com/questions/60252919/simple-code-to-verify-saxon-can-load-an-xml-file-and-optionally-schema?noredirect=1#comment106577884_60252919
  [2]: https://www.saxonica.com/download/saxon-resources9-9.zip
  [3]: https://www.saxonica.com/download/dotnet.xml
</code>```

答:
I think Martin Honnen may have answered your question in a comment on the original question?

The resources ZIP that you reference as [2] has folders samples/java and samples/cs with Java and C# examples respectively; both include sample code for invoking XSD validation. The C# version is at line 2550 of ExamplesEE.cs.

An alternative approach is to use a DocumentBuilder having first called setSchemaValidator() to make it do schema validation while building.

Body:
[In this question][1] it was recommended I look at the Saxon EE validate example. Where can I download it? It's not in [this] [2] or [this] [3].

  [1]: https://stackoverflow.com/questions/60252919/simple-code-to-verify-saxon-can-load-an-xml-file-and-optionally-schema?noredirect=1#comment106577884_60252919
  [2]: https://www.saxonica.com/download/saxon-resources9-9.zip
  [3]: https://www.saxonica.com/download/dotnet.xml


问:
Proper way to deal with HtmlUnit warnings about invalid CSS in Bootstrap 4?
HtmlUnit doesn't like Bootstrap 4:

```<code>15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:10] Error in style rule. (Invalid token "-". Was expecting one of: <EOF>, <S>, <IDENT>, "}", ";", "*".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS warning: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:10] Ignoring the following declarations in this rule. @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:25994] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26179] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26214] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26313] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26346] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26430] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26464] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:28266] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:29049] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:63092] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:63985] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64088] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64236] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64337] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64707] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64951] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:76681] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:76939] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77255] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77322] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77365] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77439] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77484] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:91815] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:93398] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:96505] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:97099] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:97756] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:98603] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:99272] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:99314] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
</code>```

What is the proper way to deal with this? Can I shutoff warnings for just bootstrap.min.css?

I don't want to disable all warnings; I find it helpful to see warnings about CSS in my own project.

答:
Write your own implementation of com.gargoylesoftware.css.parser.CSSErrorHandler and register it at the WebClient.

In your implementation you can check the uri of the CSSParseExceptions and log only if the exception is not from the bootstrap file.

For your implementation you can subclass or decorate the com.gargoylesoftware.htmlunit.DefaultCssErrorHandler if you like.

Body:
HtmlUnit doesn't like Bootstrap 4:

15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:10] Error in style rule. (Invalid token "-". Was expecting one of: <EOF>, <S>, <IDENT>, "}", ";", "*".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS warning: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:10] Ignoring the following declarations in this rule. @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:25994] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26179] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26214] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26313] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26346] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26430] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:26464] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:28266] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:29049] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:63092] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:63985] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64088] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64236] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64337] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64707] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:64951] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:76681] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:76939] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77255] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77322] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77365] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77439] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:77484] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:91815] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:93398] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:96505] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:97099] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:97756] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:98603] Error in expression. (Invalid token "(". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", <PLUS>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:99272] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error
15:06:26 WARNING: CSS error: 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' [6:99314] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <REM>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".) @com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error

What is the proper way to deal with this? Can I shutoff warnings for just bootstrap.min.css?

I don't want to disable all warnings; I find it helpful to see warnings about CSS in my own project.


问:
How correctly filter column with data separated by a comma?
Let's say I have such DataFrame.

```<code>+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
|56,89      |
+-----------+
</code>```

Also, I have an array with numbers: var array = Array(200, 73).

I want to filter this DataFrame by the array and take such a result:

```<code>+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
+-----------+
</code>```

I used such code but it doesn't work the way I thought it would

```<code>df.filter(col("amount").isin(array: _*))
</code>```

My next code returns such a result:

```<code>+-----------+
|amount     |
+-----------+
|73         |
+-----------+
</code>```

What's wrong I did?

答:
split the column into array of strings, intersect with a literal column of values you need to filter, and then check whether the result size is larger than zero:

```<code>val df = sc.parallelize(Seq("100,200,300", "73", "56,89")).toDF("amount")
// df: org.apache.spark.sql.DataFrame = [amount: string]

val array = Array("200", "73")
// array: Array[String] = Array(200, 73)

df.filter(size(array_intersect(split($"amount", ","), lit(array))) > 0).show
+-----------+
|     amount|
+-----------+
|100,200,300|
|         73|
+-----------+
</code>```

Body:
Let's say I have such DataFrame.

+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
|56,89      |
+-----------+

Also, I have an array with numbers: var array = Array(200, 73).

I want to filter this DataFrame by the array and take such a result:

+-----------+
|amount     |
+-----------+
|100,200,300|
|73         |
+-----------+

I used such code but it doesn't work the way I thought it would

df.filter(col("amount").isin(array: _*))

My next code returns such a result:

+-----------+
|amount     |
+-----------+
|73         |
+-----------+

What's wrong I did?

Body:
split the column into array of strings, intersect with a literal column of values you need to filter, and then check whether the result size is larger than zero:

val df = sc.parallelize(Seq("100,200,300", "73", "56,89")).toDF("amount")
// df: org.apache.spark.sql.DataFrame = [amount: string]

val array = Array("200", "73")
// array: Array[String] = Array(200, 73)

df.filter(size(array_intersect(split($"amount", ","), lit(array))) > 0).show
+-----------+
|     amount|
+-----------+
|100,200,300|
|         73|
+-----------+


问:
Force Browser to send post data as ISO-8859-1 and not UTF-8
I have to send an post request to a server (IBM z/VSE with CICS TS 2.1) who can not decode UTF-8 data.

So I have to force the browser or my javascript ajax post call not to translate to UTF-8. I already got it working that he removes the charset=UTF-8 string from content-type header by setting own contentType in jquery ajax call. So server already thinking that it is ISO-8859-1, which he can decode to EBCDIC. But with the german Umlaute I still have problems. "HALLÖ" for example. Because the Browsers still do the translation to UTF-8 before sending:

```<code>        let data = $('#customerForm').serialize();
        let url = "http://192.168.200.1:7080/cics/CWBA/mypgm";

        data = data + '&action=save&segment=cusadr&lfnr=01';

        $.ajax({
          type: "POST",
          url: url,
          data: data,
          contentType: "application/x-www-form-urlencoded",
          success: function(data) {
            console.log(data);

            if (resp.code != "0000") {
              app.$data.errorMsg = resp.data;
            }
          }
        });
</code>```

How could I do the post in ISO-8859-1??

答:
I realize this question was posted over 2 years ago, but it seems nobody has followed up to document the straightforward, simple answer. So here's the answer....

By coincidence it seems, on the very same day Andi S. posted this question IBM publicly announced z/VSE 6.2. z/VSE 6.2 and its accompanying CICS Transaction Server release (Version 2.2) became generally available on December 1, 2017. CICS Transaction Server Version 2.2 for z/VSE added UTF-8 and UTF-16 support to the CICS channels and containers API. The z/VSE SOAP engine and the new z/VSE REST engine inherit this support. There should no longer be any requirement for any intermediate conversion step.

While z/VSE 6.1 reached IBM's End of (Standard) Support on June 30, 2019, for those who are still running a prior release of z/VSE and CICS who are not quite ready to move everything to the latest release, it's possible to run CICS Transaction Server Version 2.2 for z/VSE alongside a prior release and to connect them up. Probably the easiest way is to have a pair of LPARs (or z/VM guests), one running the latest CICS release with UTF-8 and UTF-16 support acting as a "gateway," and the other, interconnected, older release running the CICS application programs. Then you can shift the programs over to the new, updated LPAR or z/VM guest as expeditiously as possible, but you don't have to wait for the older release environment to be entirely upgraded in order to support UTF-8 and UTF-16 interoperability.

Even if you're still running a z/VSE release prior to z/VSE 6.1, this "mixed CICS release" approach should work fine if you need it. (CICS has no particular interconnection limitations between releases and even between platforms as long as you are using one of the "lowest common denominator" interconnection choices that both/all CICS environments support.) Please note that IBM ended "Single Version Charge" limitations in early 2017. Double check with IBM of course, but there should be no additional charge to run two or more versions of z/VSE and CICS for however long you need to until you get your programs moved up to the latest releases.

Body:
I have to send an post request to a server (IBM z/VSE with CICS TS 2.1) who can not decode UTF-8 data.

So I have to force the browser or my javascript ajax post call not to translate to UTF-8. I already got it working that he removes the charset=UTF-8 string from content-type header by setting own contentType in jquery ajax call. So server already thinking that it is ISO-8859-1, which he can decode to EBCDIC. But with the german Umlaute I still have problems. "HALLÖ" for example. Because the Browsers still do the translation to UTF-8 before sending:

        let data = $('#customerForm').serialize();
        let url = "http://192.168.200.1:7080/cics/CWBA/mypgm";

        data = data + '&action=save&segment=cusadr&lfnr=01';

        $.ajax({
          type: "POST",
          url: url,
          data: data,
          contentType: "application/x-www-form-urlencoded",
          success: function(data) {
            console.log(data);

            if (resp.code != "0000") {
              app.$data.errorMsg = resp.data;
            }
          }
        });

How could I do the post in ISO-8859-1??


问:
Next is not defined next(err)
```<code>    var fs = require('fs');
    var path = require('path');
    var walk = require('walk');
    var xml2js = require('xml2js');

    var jsonDir ;
    var convertXml = function (xml_dir, json_dir) {
        jsonDir =  json_dir;

        var walker = walk.walk(xml_dir, { followLinks: true });
        walker.on("errors", fDirWalkError);
        walker.on("end", fDirWalkEnd);
        walker.on("file", fDirWalkFile);

    }

    function fDirWalkError (err) {
        console.log ("fDirWalkError: " + err);
        next (err);
    }

    function fDirWalkEnd  () {
        console.log ("======= End of directory walk");
    }

    function fDirWalkFile (root, fileStat, next) {
        if (fileStat.name.indexOf(".xml") < 0) {
            console.log ("skipping file " + fileStat.name + " (does not end in .xml)");
            return;
        } else {
            var xml_file = path.resolve(root, fileStat.name);
            console.log ("xml file: " + xml_file);

            fs.readFile('xml_file', function (err, data) {
                if (err) {
                    console.log ("error reading file:" + xml_file);
                    next (err);
                }
                xml2js.parseString (data, function (err, json_obj) {
                    if (err) {
                        console.log (err);
                        next (err);
                    }
                    var json_string = JSON.stringify(json_obj, null, 2);
                    var json_file = path.resolve (jsonDir, path.basename(xml_file).replace(/\.xml$/, ".json"));
                    console.log ("json file: ", json_file);

                    fs.writeFile(json_file, json_string, "utf8", function (err) {
                        if (err) {
                            console.log ("error converting yin (%s) to json(%s)", xml_file, json_file);
                            next (new Error ("error converting xml(" + xml_file + ") to json(" + json_file + ")"));
                        }
                        else {
                            console.log ("Converted xml (%s) to json(%s)", xml_file, json_file);
                        }
                    });
                });
            });
        }
        next ();
    }

module.exports.convertXml = convertXml;

var path = require ('path');
var xml2js = require ('./xml2js');
console.log ("__dirname: " + __dirname);
var templateDir = path.resolve (__dirname);
var xmlDir = path.resolve (templateDir, "xml");
var jsonDir = path.resolve (templateDir, "jsons");
console.log( templateDir);
xml2js.convertXml (xmlDir, jsonDir)
</code>```

/Users//Documents/GitHub//xml2js.js:19
          next (err);
          ^

ReferenceError: next is not defined
      at Walker.fDirWalkError (/Users//Documents/GitHub//xml2js.js:19:9)
      at Walker.emit (events.js:321:20)
      at Walker._wPostFilesHandler (/UsersDocuments/GitHub//node_modules/walk/lib/walk.js:134:10)
      at /Users//Documents/GitHub//node_modules/foreachasync/forEachAsync.js:15:16
      at Array.forEach ()
      at Walker.next [as _wCurFileCallback] (/Users//Documents/GitHub/node_modules/foreachasync/forEachAsync.js:14:15)
      at Walker._wLstatHandler (/Users//Documents/GitHub//node_modules/walk/lib/walk.js:84:10)
      at /Users//Documents/GitHub//node_modules/walk/lib/walk.js:106:12

答:
depends on the walk documentation at https://www.npmjs.com/package/walk

the next param is the third param that the event send

in your case you are using

```<code>function fDirWalkError (err) {
    console.log ("fDirWalkError: " + err);
    next (err);
}
</code>```

but you didnt get next function from the module in your function args

try to put it in your handler args

like this

```<code>function fDirWalkError (err, nodeStatsArray, next) {
    console.log ("fDirWalkError: " + err);
    next (err);
}
</code>```

it should work

Title: Next is not defined next(err)

Body:
    var fs = require('fs');
    var path = require('path');
    var walk = require('walk');
    var xml2js = require('xml2js');

    var jsonDir ;
    var convertXml = function (xml_dir, json_dir) {
        jsonDir =  json_dir;

        var walker = walk.walk(xml_dir, { followLinks: true });
        walker.on("errors", fDirWalkError);
        walker.on("end", fDirWalkEnd);
        walker.on("file", fDirWalkFile);

    }

    function fDirWalkError (err) {
        console.log ("fDirWalkError: " + err);
        next (err);
    }

    function fDirWalkEnd  () {
        console.log ("======= End of directory walk");
    }

    function fDirWalkFile (root, fileStat, next) {
        if (fileStat.name.indexOf(".xml") < 0) {
            console.log ("skipping file " + fileStat.name + " (does not end in .xml)");
            return;
        } else {
            var xml_file = path.resolve(root, fileStat.name);
            console.log ("xml file: " + xml_file);

            fs.readFile('xml_file', function (err, data) {
                if (err) {
                    console.log ("error reading file:" + xml_file);
                    next (err);
                }
                xml2js.parseString (data, function (err, json_obj) {
                    if (err) {
                        console.log (err);
                        next (err);
                    }
                    var json_string = JSON.stringify(json_obj, null, 2);
                    var json_file = path.resolve (jsonDir, path.basename(xml_file).replace(/\.xml$/, ".json"));
                    console.log ("json file: ", json_file);

                    fs.writeFile(json_file, json_string, "utf8", function (err) {
                        if (err) {
                            console.log ("error converting yin (%s) to json(%s)", xml_file, json_file);
                            next (new Error ("error converting xml(" + xml_file + ") to json(" + json_file + ")"));
                        }
                        else {
                            console.log ("Converted xml (%s) to json(%s)", xml_file, json_file);
                        }
                    });
                });
            });
        }
        next ();
    }

module.exports.convertXml = convertXml;

var path = require ('path');
var xml2js = require ('./xml2js');
console.log ("__dirname: " + __dirname);
var templateDir = path.resolve (__dirname);
var xmlDir = path.resolve (templateDir, "xml");
var jsonDir = path.resolve (templateDir, "jsons");
console.log( templateDir);
xml2js.convertXml (xmlDir, jsonDir)

/Users//Documents/GitHub//xml2js.js:19
          next (err);
          ^

ReferenceError: next is not defined
      at Walker.fDirWalkError (/Users//Documents/GitHub//xml2js.js:19:9)
      at Walker.emit (events.js:321:20)
      at Walker._wPostFilesHandler (/UsersDocuments/GitHub//node_modules/walk/lib/walk.js:134:10)
      at /Users//Documents/GitHub//node_modules/foreachasync/forEachAsync.js:15:16
      at Array.forEach ()
      at Walker.next [as _wCurFileCallback] (/Users//Documents/GitHub/node_modules/foreachasync/forEachAsync.js:14:15)
      at Walker._wLstatHandler (/Users//Documents/GitHub//node_modules/walk/lib/walk.js:84:10)
      at /Users//Documents/GitHub//node_modules/walk/lib/walk.js:106:12

Body:
depends on the walk documentation at https://www.npmjs.com/package/walk

the next param is the third param that the event send

in your case you are using

function fDirWalkError (err) {
    console.log ("fDirWalkError: " + err);
    next (err);
}

but you didnt get next function from the module in your function args

try to put it in your handler args

like this

function fDirWalkError (err, nodeStatsArray, next) {
    console.log ("fDirWalkError: " + err);
    next (err);
}

it should work


问:
Garbage Collection to Table
I was wondering what the best way would be to go about collecting everything from garbage collection and putting it into a table to be sorted through.

```<code>function CollectGarbageCollection()
  return collectgarbage();
end

for i,v in next, CollectGarbageCollection() do
    print(i,v) -- Data from Garbage Collection
end
</code>```

Code above is just an example.

答:
You can't. The whole point of garbage collection is that, after they are collected, objects are gone. You can add a metamethod to your own objects that triggers when they are garbage-collected, but that's it.

EDIT: Technically, you could build a patched version of Lua with some hook that gets triggered every time an object gets collected, right before its __gc metamethod, but that'd be a bunch of work.

Title: Garbage Collection to Table

Body:
I was wondering what the best way would be to go about collecting everything from garbage collection and putting it into a table to be sorted through.

function CollectGarbageCollection()
  return collectgarbage();
end

for i,v in next, CollectGarbageCollection() do
    print(i,v) -- Data from Garbage Collection
end

Code above is just an example.


问:
How do you call a JSON web service, that requires basic authentication, using jQuery?
I am somewhat novice at javascript, but I am trying to call a JSON web service that require basic authentication using jQuery (or anything that would work really). </p>

<p>I've not been able to come up with any real answers on Google. Is what I am trying to do possible? </p>

答:
You will need to set the appropriate request header to pass the credentials.  For example see here.

```<code>$.getJSON({
    'url': 'http://host.com/action/',
    'otherSettings': 'othervalues',
    'beforeSend': function(xhr) {
        //May need to use "Authorization" instead
        xhr.setRequestHeader("Authentication",
            "Basic " + encodeBase64(username + ":" + password)
    },
    success: function(result) {
        alert('done');
    }
});
</code>```

FYI I searched Google for jquery post with basic auth and this was the first link.

Body:
I am somewhat novice at javascript, but I am trying to call a JSON web service that require basic authentication using jQuery (or anything that would work really).

I've not been able to come up with any real answers on Google. Is what I am trying to do possible?

Body:
You will need to set the appropriate request header to pass the credentials.  For example see here.

$.getJSON({
    'url': 'http://host.com/action/',
    'otherSettings': 'othervalues',
    'beforeSend': function(xhr) {
        //May need to use "Authorization" instead
        xhr.setRequestHeader("Authentication",
            "Basic " + encodeBase64(username + ":" + password)
    },
    success: function(result) {
        alert('done');
    }
});

FYI I searched Google for jquery post with basic auth and this was the first link.


问:
Deprecation of _writeBarrier()
I've recently upgraded the version of visual studio (2019) I'm working on and am recompiling an fairly old codebase written by a previous developer. I'm getting the following issue during compilation:

C3861: '_WriteBarrier': identifier not found

This originates from the following block of code:

```<code>inline void SetValueWithRelease(volatile unsigned int* p, int newval)
{ *p = newval; _WriteBarrier(); }
</code>```

My understanding of _writebarrier is very limited, but I believe the purpose of that intrinsic is to ensure that, in a multi-threaded environment, the compiler doesn't try to be to "clever" in optimizing the code and ends up allowing other threads to inadvertently use an uninstantiated version of p.

But as for getting past this issue of deprecation, from what I've read, my best option is to use atomic_thread_fence:
https://learn.microsoft.com/en-us/cpp/standard-library/atomic-functions?view=vs-2019#atomic_thread_fence

Assuming that's correct, I'm inclined to use the "memory_order_seq_cst" memory order option in this function, but I'm not sure.

I'd appreciate any input or direction to clear explanations.

答:
Ideally you could convert from hand-rolled atomics with volatile into using atomic<int> *p with p->store(newval, std::memory_order_release);  Otherwise you're at the mercy of the compiler as far as interaction between volatile and atomic thread fences.

I'd guess atomic_thread_fence(std::memory_order_release) should work fine on existing compilers to make a hand-rolled relaxed store with volatile into a release-store.

Title: Deprecation of _writeBarrier()

Body:
I've recently upgraded the version of visual studio (2019) I'm working on and am recompiling an fairly old codebase written by a previous developer. I'm getting the following issue during compilation:

C3861: '_WriteBarrier': identifier not found

This originates from the following block of code:

inline void SetValueWithRelease(volatile unsigned int* p, int newval)
{ *p = newval; _WriteBarrier(); }

My understanding of _writebarrier is very limited, but I believe the purpose of that intrinsic is to ensure that, in a multi-threaded environment, the compiler doesn't try to be to "clever" in optimizing the code and ends up allowing other threads to inadvertently use an uninstantiated version of p.

But as for getting past this issue of deprecation, from what I've read, my best option is to use atomic_thread_fence:
https://learn.microsoft.com/en-us/cpp/standard-library/atomic-functions?view=vs-2019#atomic_thread_fence

Assuming that's correct, I'm inclined to use the "memory_order_seq_cst" memory order option in this function, but I'm not sure.

I'd appreciate any input or direction to clear explanations.


问:
How to add item to immutable array in React setState in Typescript?
I want to use an immutable array to handle the state. And add an item to this list.

interface MainState {
  list: readonly []; // define immutable array
}

const Component: React.FC = () => {
  // by default use the immutable array with type
  const [classes, setClasses] = useState({ list: [] } as MainState);

  useEffect(() => {
    if (data) {
      data.forEach((thing) => {
        setClasses(prevState => {
          //
          // Call signature return types '{ list: never[]; }' and 'MainState' are incompatible.
          // The types of 'list.length' are incompatible between these types.
          // Type 'number' is not assignable to type '0'.  TS2345
          //
          const list = prevState.list.concat(thing);
          return { list };
        });
      });
    }
  });
// ...

}
```

I though using concat would work, since it returns a new array.

答:
From the doc you provided:

The concat() method is used to merge two or more arrays

So you need to pass array, not element to this function, I suppose this will work:

```<code>const list = prevState.list.concat([thing]);
</code>```

Also I see your code is iterating through new array and pass elements one by one, why don't you concat the whole array?

```<code>    if (data) {
        setClasses(prevState => {
          const list = prevState.list.concat(data);
          // or list = [...prevState.list, ...data];
          return { list };
        });
    }
</code>```

Also I think you missed type of array in you MainState, at least update it with any type, here is full example for number type:

```<code>interface MainState {
  list: readonly number[];
}

const data = [1, 2, 3]

const Component: React.FC = () => {

  const [classes, setClasses] = useState({ list: [] } as MainState);

  useEffect(() => {
    if (data) {
      setClasses(prevState => ({ list: [...prevState.list, ...data]}));
    }
  });

  return <div>{classes}</div>
}
</code>```

Body:
I want to use an immutable array to handle the state. And add an item to this list.

interface MainState {
  list: readonly []; // define immutable array
}

const Component: React.FC = () => {
  // by default use the immutable array with type
  const [classes, setClasses] = useState({ list: [] } as MainState);

  useEffect(() => {
    if (data) {
      data.forEach((thing) => {
        setClasses(prevState => {
          //
          // Call signature return types '{ list: never[]; }' and 'MainState' are incompatible.
          // The types of 'list.length' are incompatible between these types.
          // Type 'number' is not assignable to type '0'.  TS2345
          //
          const list = prevState.list.concat(thing);
          return { list };
        });
      });
    }
  });
// ...

}

I though using concat would work, since it returns a new array.

Body:
From the doc you provided:

The concat() method is used to merge two or more arrays

So you need to pass array, not element to this function, I suppose this will work:

const list = prevState.list.concat([thing]);

Also I see your code is iterating through new array and pass elements one by one, why don't you concat the whole array?

    if (data) {
        setClasses(prevState => {
          const list = prevState.list.concat(data);
          // or list = [...prevState.list, ...data];
          return { list };
        });
    }

Also I think you missed type of array in you MainState, at least update it with any type, here is full example for number type:

interface MainState {
  list: readonly number[];
}

const data = [1, 2, 3]

const Component: React.FC = () => {

  const [classes, setClasses] = useState({ list: [] } as MainState);

  useEffect(() => {
    if (data) {
      setClasses(prevState => ({ list: [...prevState.list, ...data]}));
    }
  });

  return <div>{classes}</div>
}


问:
How to create Custom Analyzer in Lucene, with custom stop/common words from file
I m trying to create a custom analyzer in Lucene 8.3.0 that uses stemming and filters the given text using custom stop words from a file.
To be more clear, I don't want to use the default stop words filter and add some words on it, I want to filter using only a set of stop words from a stopWords.txt file.
How can I do this?

This is what I have written until now, but I am not sure if it is right

```<code>public class MyAnalyzer extends Analyzer{
    //public class MyAnalyzer extends Analyzer {
    @Override
    protected TokenStreamComponents createComponents(String fieldName) {
       // public TokenStream tokenStream(String fieldName, Reader reader) {
        Tokenizer tokenizer = new StandardTokenizer();
        TokenStream tokenStream = new StandardFilter(tokenizer);
        tokenStream = new LowerCaseFilter(tokenStream);
        tokenStream = new StopFilter(tokenStream,StopAnalyzer.ENGLISH_STOP_WORDS_SET);
        //Adding Porter Stemming filtering
        tokenStream = new PorterStemFilter(tokenStream);
        //return tokenStream;
        return new TokenStreamComponents(tokenizer, tokenStream);
    }
}
</code>```

First of all I am not sure if the structure is correct and for now I am using the StopFilter from StopAnalyzer just to test it (however it's not working).

答:
You need to read the file and parse it to a CharArraySet to pass into the filter. StopFilter has some built in methods you can use to convert a List of Strings to a CharArraySet, like:

```<code>...
CharArraySet stopset = StopFilter.makeStopSet(myStopwordList);
tokenStream = new StopFilter(tokenStream, stopset);
...
</code>```

It's listed as for internal purposes, so fair warning about relying on this class, but if you don't want to have to handle parsing your file to a list, you could use WordListLoader to parse your stopword file into a CharArraySet, something like:

```<code>...
CharArraySet stopset = WordlistLoader.getWordSet(myStopfileReader);
tokenStream = new StopFilter(tokenStream, stopset);
...
</code>```

Body:
I m trying to create a custom analyzer in Lucene 8.3.0 that uses stemming and filters the given text using custom stop words from a file.
To be more clear, I don't want to use the default stop words filter and add some words on it, I want to filter using only a set of stop words from a stopWords.txt file.
How can I do this?

This is what I have written until now, but I am not sure if it is right

public class MyAnalyzer extends Analyzer{
    //public class MyAnalyzer extends Analyzer {
    @Override
    protected TokenStreamComponents createComponents(String fieldName) {
       // public TokenStream tokenStream(String fieldName, Reader reader) {
        Tokenizer tokenizer = new StandardTokenizer();
        TokenStream tokenStream = new StandardFilter(tokenizer);
        tokenStream = new LowerCaseFilter(tokenStream);
        tokenStream = new StopFilter(tokenStream,StopAnalyzer.ENGLISH_STOP_WORDS_SET);
        //Adding Porter Stemming filtering
        tokenStream = new PorterStemFilter(tokenStream);
        //return tokenStream;
        return new TokenStreamComponents(tokenizer, tokenStream);
    }
}

First of all I am not sure if the structure is correct and for now I am using the StopFilter from StopAnalyzer just to test it (however it's not working).

Body:
You need to read the file and parse it to a CharArraySet to pass into the filter. StopFilter has some built in methods you can use to convert a List of Strings to a CharArraySet, like:

...
CharArraySet stopset = StopFilter.makeStopSet(myStopwordList);
tokenStream = new StopFilter(tokenStream, stopset);
...

It's listed as for internal purposes, so fair warning about relying on this class, but if you don't want to have to handle parsing your file to a list, you could use WordListLoader to parse your stopword file into a CharArraySet, something like:

...
CharArraySet stopset = WordlistLoader.getWordSet(myStopfileReader);
tokenStream = new StopFilter(tokenStream, stopset);
...


问:
Extracting a step from a text file and placing into a list with Python
I am opening a txt and assigning every third word to go into a list called three.

I thought this would step correctly, but I am just getting the entire file as a list.

```<code>three=[]

with open('school_prompt.txt', 'r') as f:
    for line in f.split()[::3]:
        three.append(line)
</code>```

答:
Here is the simple way of doing:

```<code>three = []
with open("school_prompt.txt", "r") as f:
    # read the entire file to process
    doc = f.read()
    # split the document
    word_list = doc.split()
    # extract every third word from the document
    three = word_list[::3]
</code>```

Hope it helps you!

Body:
I am opening a txt and assigning every third word to go into a list called three.

I thought this would step correctly, but I am just getting the entire file as a list.

three=[]

with open('school_prompt.txt', 'r') as f:
    for line in f.split()[::3]:
        three.append(line)

Body:
Here is the simple way of doing:

three = []
with open("school_prompt.txt", "r") as f:
    # read the entire file to process
    doc = f.read()
    # split the document
    word_list = doc.split()
    # extract every third word from the document
    three = word_list[::3]

Hope it helps you!