问:
How to fix error in step function (stepcACI): rep(no, length.out = len)
I got the following error running the stepcAIC function in a linear mixed effect model (lmer):

Fehler in rep(no, length.out = len) :
attempt to replicate an object of type 'language'

I don't understand what the error is saying. All the factors are declared as "factors" and all the other variables as "numeric". The storage.mode is "integer" for the factors and "double" for the other variables.

This is my model and the step function:

biom_FULLO<-lmer((above_bio)~MUM_germ_time+MUM_num_seed+MUM_av_seed_mass+
          MUM_num_inf+MUM_above_bio+MUM_total_bio+MUM_inf_size+MUM_root_bio+
          MUM_CV_seed_mass+MUM_CV_SEM_per_inflor+MUM_CV_inflor_size+
          MUM_seed_weight+germ_date_year+germ_time+flow_start_date+
          height_3m+height_flow+num_inf+seed_gen+Early+
          Late+seed_gen:Early+seed_gen:Late+
          Early:Late+seed_gen:Early:Late+(1|ID_year), DT_gen_biom)

biom_step<-stepcAIC(biom_FULLO, direction = "backward",
      trace = FALSE, data = DT_gen_biom)
```
<p>Any idea anyone?</p>
<p>P.D.: traceback()</p>
```6: ifelse(wasGam, formula(modelInit$gam)[[2]], formula(modelInit)[[2]])
5: makeFormula(x, modelInit)
4: FUN(X[[i]], ...)
3: lapply(newSetup, function(x) makeFormula(x, modelInit))
2: calculateAllCAICs(newSetup = newSetup, modelInit = object, numCores = numCores,
       data = data, calcNonOptimMod = calcNonOptimMod, nrmods = numberOfSavedModels,
       ...)
1: stepcAIC(biom_FULLO, direction = "backward", trace = FALSE, data = DT_gen_biom)
```

答:
Just remove the parenthesis of your response variable in the LHS of your formula:

library(cAIC4)
#> Loading required package: lme4
#> Loading required package: Matrix
#> Loading required package: stats4
#> Loading required package: nlme
#>
#> Attaching package: 'nlme'
#> The following object is masked from 'package:lme4':
#>
#>     lmList
library(lme4)

m1 <- lmer((Sepal.Length) ~ Sepal.Width + (1|Species), data = iris)
stepcAIC(m1)
#> Warning in nobars(formula(modelInit)) == formula(modelInit)[[2]]: longer object
#> length is not a multiple of shorter object length
#> Error in rep(no, length.out = len): attempt to replicate an object of type 'language'

m2 <- lmer(Sepal.Length ~ Sepal.Width + (1|Species), data = iris)
stepcAIC(m2)
#> $finalModel
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Sepal.Length ~ Sepal.Width + (1 | Species)
#>    Data: iris
#> REML criterion at convergence: 194.6361
#> Random effects:
#>  Groups   Name        Std.Dev.
#>  Species  (Intercept) 1.010
#>  Residual             0.438
#> Number of obs: 150, groups:  Species, 3
#> Fixed Effects:
#> (Intercept)  Sepal.Width
#>      3.4062       0.7972
#>
#> $additionalModels
#> NULL
#>
#> $bestCAIC
#> [1] 184.0044
```

Created on 2022-02-11 by the reprex package (v2.0.0)

Body:
I got the following error running the stepcAIC function in a linear mixed effect model (lmer):

Fehler in rep(no, length.out = len) :
attempt to replicate an object of type 'language'

I don't understand what the error is saying. All the factors are declared as "factors" and all the other variables as "numeric". The storage.mode is "integer" for the factors and "double" for the other variables.

This is my model and the step function:

biom_FULLO<-lmer((above_bio)~MUM_germ_time+MUM_num_seed+MUM_av_seed_mass+
          MUM_num_inf+MUM_above_bio+MUM_total_bio+MUM_inf_size+MUM_root_bio+
          MUM_CV_seed_mass+MUM_CV_SEM_per_inflor+MUM_CV_inflor_size+
          MUM_seed_weight+germ_date_year+germ_time+flow_start_date+
          height_3m+height_flow+num_inf+seed_gen+Early+
          Late+seed_gen:Early+seed_gen:Late+
          Early:Late+seed_gen:Early:Late+(1|ID_year), DT_gen_biom)

biom_step<-stepcAIC(biom_FULLO, direction = "backward",
      trace = FALSE, data = DT_gen_biom)

Any idea anyone?

P.D.: traceback()

6: ifelse(wasGam, formula(modelInit$gam)[[2]], formula(modelInit)[[2]])
5: makeFormula(x, modelInit)
4: FUN(X[[i]], ...)
3: lapply(newSetup, function(x) makeFormula(x, modelInit))
2: calculateAllCAICs(newSetup = newSetup, modelInit = object, numCores = numCores,
       data = data, calcNonOptimMod = calcNonOptimMod, nrmods = numberOfSavedModels,
       ...)
1: stepcAIC(biom_FULLO, direction = "backward", trace = FALSE, data = DT_gen_biom)

Body:
Just remove the parenthesis of your response variable in the LHS of your formula:

library(cAIC4)
#> Loading required package: lme4
#> Loading required package: Matrix
#> Loading required package: stats4
#> Loading required package: nlme
#>
#> Attaching package: 'nlme'
#> The following object is masked from 'package:lme4':
#>
#>     lmList
library(lme4)

m1 <- lmer((Sepal.Length) ~ Sepal.Width + (1|Species), data = iris)
stepcAIC(m1)
#> Warning in nobars(formula(modelInit)) == formula(modelInit)[[2]]: longer object
#> length is not a multiple of shorter object length
#> Error in rep(no, length.out = len): attempt to replicate an object of type 'language'

m2 <- lmer(Sepal.Length ~ Sepal.Width + (1|Species), data = iris)
stepcAIC(m2)
#> $finalModel
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: Sepal.Length ~ Sepal.Width + (1 | Species)
#>    Data: iris
#> REML criterion at convergence: 194.6361
#> Random effects:
#>  Groups   Name        Std.Dev.
#>  Species  (Intercept) 1.010
#>  Residual             0.438
#> Number of obs: 150, groups:  Species, 3
#> Fixed Effects:
#> (Intercept)  Sepal.Width
#>      3.4062       0.7972
#>
#> $additionalModels
#> NULL
#>
#> $bestCAIC
#> [1] 184.0044

Created on 2022-02-11 by the reprex package (v2.0.0)


来源: stackexchange

问:
What the difference between Angular [checked] attribute and formControl setValue?
Why if i update component property, that assigned to [checked] input, in method that called after checkbox changed the value of checkbox doesn't change.

But if i assign Form Control to same checkbox and call setValue checked status of that checkbox will change?

live code example
https://codesandbox.io/s/magical-robinson-mzpx9?file=/src/app/app.component.ts

app.component.html

```<code><input
  type="checkbox"
  [checked]="haveValue"
  (change)="valueChanged($event.target)"
  [formControl]="checkboxControl"
/>

<dialog #modal>
  <form method="dialog">
    <button value="default">Ok</button>
    <button (click)="cancel()" value="cancel">Cancel</button>
  </form>
</dialog>
</code>```

app.component.ts

```<code>export class AppComponent {
  haveValue = true;
  @ViewChild("modal") modal: ElementRef<HTMLDialogElement>;

  checkboxControl = new FormControl(true);

  valueChanged(target: EventTarget): void {
    const checked = (target as HTMLInputElement).checked;
    if (!checked) {
      this.modal.nativeElement.showModal();
    }
  }

  cancel(): void {
    // if replace with 'this.haveValue = true' checked satus will not changed
    this.checkboxControl.setValue(true);
    //this.haveValue = true;
    console.log("cancel called");
  }
}
</code>```

答:
Angular bindings react on changes. so this.haveValue = true; should change haveValue from false to true for checkbox to react.
so correct code would look like

```<code>valueChanged(target: EventTarget): void {
    const checked = (target as HTMLInputElement).checked;
    this.haveValue = checked; // here it is changed to false
    if (!checked) {
      this.modal.nativeElement.showModal();
    }
  }

 cancel(): void {
    this.haveValue = true; // back to true
 }

</code>```

ContentLicense: CC BY-SA 4.0

Body:
Why if i update component property, that assigned to [checked] input, in method that called after checkbox changed the value of checkbox doesn't change.

But if i assign Form Control to same checkbox and call setValue checked status of that checkbox will change?

live code example
https://codesandbox.io/s/magical-robinson-mzpx9?file=/src/app/app.component.ts

app.component.html

<input
  type="checkbox"
  [checked]="haveValue"
  (change)="valueChanged($event.target)"
  [formControl]="checkboxControl"
/>

<dialog #modal>
  <form method="dialog">
    <button value="default">Ok</button>
    <button (click)="cancel()" value="cancel">Cancel</button>
  </form>
</dialog>

app.component.ts

export class AppComponent {
  haveValue = true;
  @ViewChild("modal") modal: ElementRef<HTMLDialogElement>;

  checkboxControl = new FormControl(true);

  valueChanged(target: EventTarget): void {
    const checked = (target as HTMLInputElement).checked;
    if (!checked) {
      this.modal.nativeElement.showModal();
    }
  }

  cancel(): void {
    // if replace with 'this.haveValue = true' checked satus will not changed
    this.checkboxControl.setValue(true);
    //this.haveValue = true;
    console.log("cancel called");
  }
}

Body:
Angular bindings react on changes. so this.haveValue = true; should change haveValue from false to true for checkbox to react.
so correct code would look like

valueChanged(target: EventTarget): void {
    const checked = (target as HTMLInputElement).checked;
    this.haveValue = checked; // here it is changed to false
    if (!checked) {
      this.modal.nativeElement.showModal();
    }
  }

 cancel(): void {
    this.haveValue = true; // back to true
 }


问:
Unable to find the requested Boost libraries in cmake with conan
I have a problem to compile with cmake using the boost library in c++ from the conan dependencies in a Unix System (Ubuntu)

The sfml library is already implemented and working in the project but the boost library doesn't work and is displaying this message :

```<code>CMake Error at /usr/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:13 (find_package)
</code>```

Here is my conanfile.txt

```<code>[requires]
sfml/2.5.1@bincrafters/stable
boost/1.69.0@conan/stable

[options]
sfml:graphics=True
sfml:window=True
sfml:audio=True
sfml:network=False

[generators]
cmake
</code>```

Here is my CMakeLists.txt

```<code># Minimum version of cmake
cmake_minimum_required(VERSION 3.10)

# Setting the project
project(CPP_rtype_2019 CXX)
include(build/conanbuildinfo.cmake)

# Dependencies Sfml
find_package(SFML 2.5.1 EXACT REQUIRED COMPONENTS system window graphics audio)
find_package(Threads REQUIRED)

# Dependencies Boost
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
include_directories(${Boost_INCLUDE_DIRS})

# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11)

# Added all .hpp
include_directories(client/include)
include_directories(server/include)

# Added all .cpp
add_executable(r-type_client client/src/Actor.cpp client/src/Character.cpp client/src/Ennemy.cpp client/src/Interface.cpp client/src/Pown.cpp client/src/Projectile.cpp)
add_executable(r-type_server server/src/GameEngine.cpp)

# Added dependencies to compilation
target_link_libraries(r-type_client PRIVATE sfml-audio sfml-system sfml-graphics)
target_link_libraries(r-type_server PRIVATE Boost::thread Boost::system Boost::filesystem)
</code>```

I've tried so many solutions but no one is working. All solutions or tips are welcome, thanks !

答:
Here is the example of proper usage in readme https://github.com/conan-io/cmake-conan

No need for conanfile.txt, it is generated.

```<code>cmake_minimum_required(VERSION 3.5)
project(FormatOutput CXX)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"
                "${CMAKE_BINARY_DIR}/conan.cmake"
                EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484
                TLS_VERIFY ON)
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_configure(REQUIRES
                      boost/1.69.0
                      GENERATORS cmake_find_package)

conan_cmake_autodetect(settings)

conan_cmake_install(PATH_OR_REFERENCE .
                    BUILD missing
                    REMOTE conancenter
                    SETTINGS ${settings})

find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)

add_executable(main main.cpp)
target_link_libraries(main
     Boost::thread
     Boost::system
     Boost::filesystem)
</code>```

Body:
I have a problem to compile with cmake using the boost library in c++ from the conan dependencies in a Unix System (Ubuntu)

The sfml library is already implemented and working in the project but the boost library doesn't work and is displaying this message :

CMake Error at /usr/share/cmake-3.13/Modules/FindBoost.cmake:2100 (message):
  Unable to find the requested Boost libraries.

  Unable to find the Boost header files.  Please set BOOST_ROOT to the root
  directory containing Boost or BOOST_INCLUDEDIR to the directory containing
  Boost's headers.
Call Stack (most recent call first):
  CMakeLists.txt:13 (find_package)

Here is my conanfile.txt

[requires]
sfml/2.5.1@bincrafters/stable
boost/1.69.0@conan/stable

[options]
sfml:graphics=True
sfml:window=True
sfml:audio=True
sfml:network=False

[generators]
cmake

Here is my CMakeLists.txt

# Minimum version of cmake
cmake_minimum_required(VERSION 3.10)

# Setting the project
project(CPP_rtype_2019 CXX)
include(build/conanbuildinfo.cmake)

# Dependencies Sfml
find_package(SFML 2.5.1 EXACT REQUIRED COMPONENTS system window graphics audio)
find_package(Threads REQUIRED)

# Dependencies Boost
find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)
include_directories(${Boost_INCLUDE_DIRS})

# Set the C++11 standard
set(CMAKE_CXX_STANDARD 11)

# Added all .hpp
include_directories(client/include)
include_directories(server/include)

# Added all .cpp
add_executable(r-type_client client/src/Actor.cpp client/src/Character.cpp client/src/Ennemy.cpp client/src/Interface.cpp client/src/Pown.cpp client/src/Projectile.cpp)
add_executable(r-type_server server/src/GameEngine.cpp)

# Added dependencies to compilation
target_link_libraries(r-type_client PRIVATE sfml-audio sfml-system sfml-graphics)
target_link_libraries(r-type_server PRIVATE Boost::thread Boost::system Boost::filesystem)

I've tried so many solutions but no one is working. All solutions or tips are welcome, thanks !

Body:
Here is the example of proper usage in readme https://github.com/conan-io/cmake-conan

No need for conanfile.txt, it is generated.

cmake_minimum_required(VERSION 3.5)
project(FormatOutput CXX)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
  message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
  file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake"
                "${CMAKE_BINARY_DIR}/conan.cmake"
                EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484
                TLS_VERIFY ON)
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_configure(REQUIRES
                      boost/1.69.0
                      GENERATORS cmake_find_package)

conan_cmake_autodetect(settings)

conan_cmake_install(PATH_OR_REFERENCE .
                    BUILD missing
                    REMOTE conancenter
                    SETTINGS ${settings})

find_package(Boost 1.69.0 EXACT REQUIRED COMPONENTS thread system filesystem)

add_executable(main main.cpp)
target_link_libraries(main
     Boost::thread
     Boost::system
     Boost::filesystem)


问:
XML Export - Denormalized Data
I work for a financial firm who are required to report trades, sales data etc. to the regulator. At the moment we are doing this per individual because we cannot get their XML schema template to work. I am trying to import this into excel using the xml source pane.

The problem we have is that when we come to export the document, there is a denormalized data error which we can't get around. Unfortunately, myself and the team haven’t got much experience in mapping XML to know how to properly troubleshoot it. I’ve changed various bits of code to no success and even contacted the FCA (who say there is nothing wrong with it or dead links…lol).

Can someone offer some insight or guidance on how we can correct this issue?

The Schema is as follows:

```<code><?xml version="1.0" encoding="utf-8"?>
<!-- edited with XMLSpy v2005 U (http://www.xmlspy.com) by Clive Raven (LogicaCMG) -->
<!--
********************************************************************************
*
* Project Name : FSA Transaction Reporting System
* Reference    :
* Description  : Definition For FSA High-Street Firms Feed For Retail Investment Products
* Dependencies : http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-1.xsd
*
* Revision History
* Version   Author              Date                Description
*  1.1          FSA                 07/04/2004      First published draft
*  1.2          FSA                 22/11/2004      Final draft
*  1.3          FSA                 19/02/2007      Added Self Invested Personal Pensions (SIPPs) product type in TypeOfPolicyType
*
* Copyright Financial Services Authority 2004
********************************************************************************
-->
<xs:schema xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2"
    xmlns:cmn="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2"
    elementFormDefault="qualified"
    version="1.0"
    id="FSAHSFFeedRI-v1-3">
    <xs:import namespace="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
        schemaLocation="https://gabriel.fca.org.uk/specifications/MER/DRG/PSD-CommonTypes/v1.2/FSAFeedCommon-v1-2.xsd"/>
    <!--Types used in FSAHSFFeedRI-->
    <xs:simpleType name="TypeOfPolicyType">
        <xs:annotation>
            <xs:documentation>Retail Investment Product Code.       </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="01">
                <xs:annotation>
                    <xs:documentation>Unit trust/OEIC</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="02">
                <xs:annotation>
                    <xs:documentation>Investment trust</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="03">
                <xs:annotation>
                    <xs:documentation>ISA</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="04">
                <xs:annotation>
                    <xs:documentation>Structured capital at risk product</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="05">
                <xs:annotation>
                    <xs:documentation>With profit bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="06">
                <xs:annotation>
                    <xs:documentation>Unit linked bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="07">
                <xs:annotation>
                    <xs:documentation>Distribution bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="08">
                <xs:annotation>
                    <xs:documentation>With profit endowment</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="09">
                <xs:annotation>
                    <xs:documentation>Endowment savings plan</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="10">
                <xs:annotation>
                    <xs:documentation>Mortgage endowment</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="11">
                <xs:annotation>
                    <xs:documentation>Guaranteed income/growth/investment bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="12">
                <xs:annotation>
                    <xs:documentation>Trustee investment bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="13">
                <xs:annotation>
                    <xs:documentation>Life annuity</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="14">
                <xs:annotation>
                    <xs:documentation>Pension annuity</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="15">
                <xs:annotation>
                    <xs:documentation>Long term care insurance</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="16">
                <xs:annotation>
                    <xs:documentation>Stakeholder pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="17">
                <xs:annotation>
                    <xs:documentation>Personal pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="18">
                <xs:annotation>
                    <xs:documentation>Group personal pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="19">
                <xs:annotation>
                    <xs:documentation>FSAVC</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="20">
                <xs:annotation>
                    <xs:documentation>Individual pension transfer</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="21">
                <xs:annotation>
                    <xs:documentation>Pension opt out</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="22">
                <xs:annotation>
                    <xs:documentation>Section 32 buy out</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="23">
                <xs:annotation>
                    <xs:documentation>Group section 32 buy out</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="24">
                <xs:annotation>
                    <xs:documentation>Income drawdown</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="25">
                <xs:annotation>
                    <xs:documentation>Executive pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="26">
                <xs:annotation>
                    <xs:documentation>SSAS</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="27">
                <xs:annotation>
                    <xs:documentation>Group money purchase</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="28">
                <xs:annotation>
                    <xs:documentation>AVC final salary</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="29">
                <xs:annotation>
                    <xs:documentation>AVC group money purchase</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="30">
                <xs:annotation>
                    <xs:documentation>Self Invested Personal Pensions (SIPPs)</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="99">
                <xs:annotation>
                    <xs:documentation>Other. Use this when product is not one of above.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    <!--Structures used in FSAHSFFeedRI -->
    <xs:complexType name="RetailInvestmentStructure">
        <xs:sequence>
            <xs:element name="PrincipalOrNetworkFSARef" type="cmn:FSARefType" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>This field only applies if the sale has been made by an intermediary who has a principal or is part of a network. </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="TypePolicy" type="TypeOfPolicyType">
                <xs:annotation>
                    <xs:documentation>Type of policy.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="AdvisedSale" type="cmn:YNType" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>This field is optional until July 2006, when it will become mandatory.  Y = Sale was Advised, N = Sale was non-Advised. For PSD reporting purposes non-Advised includes execution only and direct offer transactions.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="CustPostCode" type="cmn:PostCodeType" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Full U.K postcode of customer.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="PremPaymentMethod" type="cmn:PremiumPaymentMethodType">
                <xs:annotation>
                    <xs:documentation>Method of premium/ contribution payment.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="TotalPremAmt" type="cmn:HSFStdSterlingAmountType">
                <xs:annotation>
                    <xs:documentation>Total premium/contribution amount. Annualised amount rounded to nearest pound.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="CustDOB" type="xs:date" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Date of birth of customer. Applies to first named customer at time of sale i.e. age obtained at proposal stage. Must represent an age up to and including 115.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="DateInForce" type="xs:date"/>
        </xs:sequence>
    </xs:complexType>
    <!--FSAHSFFeedRI -->
    <xs:element name="FSAHSFFeedRI">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="cmn:FSAFeedHeader"/>
                <xs:element name="FSAHSFFeedRIMsg" minOccurs="0" maxOccurs="unbounded">
                    <xs:annotation>
                        <xs:documentation>Defines the inidividual transactions</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element ref="cmn:CoreItems"/>
                            <xs:element name="RetailInvestment" type="RetailInvestmentStructure">
                                <xs:annotation>
                                    <xs:documentation>Defines the elements that are specific to a Retail Investment transaction.</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
</code>```

When importing the schema there is an error importing the common feed due to a dead link referenced in the schema:

```<code>SchemaLocation="https://gabriel.fca.org.uk/specifications/MER/DRG/PSD-CommonTypes/v1.2/FSAFeedCommon-v1-2.xsd
</code>```

This can be downloaded separately from the FCA resources section and the schema can be edited to point to the file locally. See below:

```<code><?xml version="1.0" encoding="utf-8"?>
<!-- edited with XMLSpy v2005 U (http://www.xmlspy.com) by Clive Raven (LogicaCMG) -->
<!--
********************************************************************************
*
* Project Name : FSA Transaction Reporting System
* Reference    :
* Description  : Common Definitions For FSA Feeds
* Dependencies :
*
* Revision History
* Version   Author          Date                Description
*  1.1          FSA             07/04/2004      Published with early draft of SBD Schema's
*  1.2          FSA             22/11/2004      Published with final draft of all TRS Schema's
*
* Copyright Financial Services Authority 2004
********************************************************************************
-->
<xs:schema xmlns="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
    elementFormDefault="qualified"
    version="1.2"
    id="FSAFeedCommon-v1-2">
    <!--Common Types -->
    <xs:simpleType name="NonEmptyString">
        <xs:annotation>
            <xs:documentation>Defines a string type that may not be the empty string. Values of this type are also whitespace normalized meaning all-whitespace strings are also invalid.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:whiteSpace value="collapse"/>
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="FSARefType">
        <xs:annotation>
            <xs:documentation>FSA Reference Number. Either a 6 or 7 digit number.  Leading zeroes are not expected.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[1-9]{1}[0-9]{5,6}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="PostCodeType">
        <xs:annotation>
            <xs:documentation>Full or abbreviated UK postcode.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="8"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="YNType">
        <xs:annotation>
            <xs:documentation>Y or N</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="Y"/>
            <xs:enumeration value="N"/>
        </xs:restriction>
    </xs:simpleType>
    <!--Common SBD Types -->
    <xs:simpleType name="HSFStdSterlingAmountType">
        <xs:annotation>
            <xs:documentation>Integer from 1 to 999999999. Representing sterling-equivalent amount.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:totalDigits value="9"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="PremiumPaymentMethodType">
        <xs:annotation>
            <xs:documentation>Method of Premium/Contribution payment. Single or Regular.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="S">
                <xs:annotation>
                    <xs:documentation>Single payment.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="R">
                <xs:annotation>
                    <xs:documentation>Regular payment.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
    <!--Common Structures -->
    <xs:element name="CoreItems">
        <xs:annotation>
            <xs:documentation>Defines the elements that are common to all transactions.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="FirmFSARef" type="FSARefType">
                    <xs:annotation>
                        <xs:documentation>The FSA code of the reporting firm for this transaction.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="TransRef">
                    <xs:annotation>
                        <xs:documentation>The unique reference, internal to the reporting firm, that will enable the firm to provide the FSA with more information concerning the trade if required. This reference must be unique within each report file, with the exception that a reference can occur twice if one occurrence is a cancellation. </xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="NonEmptyString">
                            <xs:maxLength value="25"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="Cancellation" type="xs:boolean" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Indicates if the transaction is a cancellation. If ommitted this is logically the same as providing a value of 'false'.</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="FSAFeedHeader">
        <xs:annotation>
            <xs:documentation>Defines the report header, common to all reports.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="FeedTargetSchemaVersion" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Identifies the version of the business specific schema to which this report conforms.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="Submitter">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="SubmittingFirm" type="FSARefType">
                                <xs:annotation>
                                    <xs:documentation>The FSA code of the firm submitting the report.</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                            <xs:element name="SubmittingDept" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The identifier of the department within the submitting firm who created this report - optional.</xs:documentation>
                                </xs:annotation>
                                <xs:simpleType>
                                    <xs:restriction base="NonEmptyString">
                                        <xs:maxLength value="20"/>
                                        <xs:pattern value="[a-zA-Z0-9]+"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="ReportDetails">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="ReportCreationDate" type="xs:date">
                                <xs:annotation>
                                    <xs:documentation>Report creation date.</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                            <xs:element name="ReportIdentifier">
                                <xs:annotation>
                                    <xs:documentation>Unique identifier for the report (wthin the context of the submitter, submitting firm, submitting department and report creation date).</xs:documentation>
                                </xs:annotation>
                                <xs:simpleType>
                                    <xs:restriction base="NonEmptyString">
                                        <xs:maxLength value="25"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
</code>```

Resources:

https://regdata.fca.org.uk/specifications/DRG/PSD002/v1.5/FSAHSFFeedRI-v1-3.xsd - Full Schema

https://regdata.fca.org.uk/specifications/DRG/PSD-CommonTypes/v1.2/FSAFeedCommon-v1-2.xsd - Schema referenced using a dead link

https://regdata.fca.org.uk/#/layout/resources - General Resources

答:
I'm not sure what your question is exactly. You point to 2 problems:

"denormalized data error": what do you mean? how is this related to the schema?

The broken link in the main schema file. You solved it yourself by editing the schemaLocation in the main schema. If you need a way to automatically correct the location without editing the main schema file, you can use an XML Catalog. Is it what you're looking for?

What do you mean also by "importing" the schema? Are you importing it in your own schema?

A catalog would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
  uri="path/to/local/copy/of/FSAFeedCommon-v1-2.xsd"/>
</catalog>
```

Then, you need to configure your parser (validation tool) to use that catalog.

Title: XML Export - Denormalized Data

Body:
I work for a financial firm who are required to report trades, sales data etc. to the regulator. At the moment we are doing this per individual because we cannot get their XML schema template to work. I am trying to import this into excel using the xml source pane.

The problem we have is that when we come to export the document, there is a denormalized data error which we can't get around. Unfortunately, myself and the team haven’t got much experience in mapping XML to know how to properly troubleshoot it. I’ve changed various bits of code to no success and even contacted the FCA (who say there is nothing wrong with it or dead links…lol).

Can someone offer some insight or guidance on how we can correct this issue?

The Schema is as follows:

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2"
    xmlns:cmn="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.fsa.gov.uk/XMLSchema/FSAHSFFeedRI-v1-2"
    elementFormDefault="qualified"
    version="1.0"
    id="FSAHSFFeedRI-v1-3">
    <xs:import namespace="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
        schemaLocation="https://gabriel.fca.org.uk/specifications/MER/DRG/PSD-CommonTypes/v1.2/FSAFeedCommon-v1-2.xsd"/>

    <xs:simpleType name="TypeOfPolicyType">
        <xs:annotation>
            <xs:documentation>Retail Investment Product Code.       </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="01">
                <xs:annotation>
                    <xs:documentation>Unit trust/OEIC</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="02">
                <xs:annotation>
                    <xs:documentation>Investment trust</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="03">
                <xs:annotation>
                    <xs:documentation>ISA</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="04">
                <xs:annotation>
                    <xs:documentation>Structured capital at risk product</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="05">
                <xs:annotation>
                    <xs:documentation>With profit bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="06">
                <xs:annotation>
                    <xs:documentation>Unit linked bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="07">
                <xs:annotation>
                    <xs:documentation>Distribution bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="08">
                <xs:annotation>
                    <xs:documentation>With profit endowment</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="09">
                <xs:annotation>
                    <xs:documentation>Endowment savings plan</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="10">
                <xs:annotation>
                    <xs:documentation>Mortgage endowment</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="11">
                <xs:annotation>
                    <xs:documentation>Guaranteed income/growth/investment bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="12">
                <xs:annotation>
                    <xs:documentation>Trustee investment bond</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="13">
                <xs:annotation>
                    <xs:documentation>Life annuity</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="14">
                <xs:annotation>
                    <xs:documentation>Pension annuity</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="15">
                <xs:annotation>
                    <xs:documentation>Long term care insurance</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="16">
                <xs:annotation>
                    <xs:documentation>Stakeholder pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="17">
                <xs:annotation>
                    <xs:documentation>Personal pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="18">
                <xs:annotation>
                    <xs:documentation>Group personal pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="19">
                <xs:annotation>
                    <xs:documentation>FSAVC</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="20">
                <xs:annotation>
                    <xs:documentation>Individual pension transfer</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="21">
                <xs:annotation>
                    <xs:documentation>Pension opt out</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="22">
                <xs:annotation>
                    <xs:documentation>Section 32 buy out</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="23">
                <xs:annotation>
                    <xs:documentation>Group section 32 buy out</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="24">
                <xs:annotation>
                    <xs:documentation>Income drawdown</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="25">
                <xs:annotation>
                    <xs:documentation>Executive pension</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="26">
                <xs:annotation>
                    <xs:documentation>SSAS</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="27">
                <xs:annotation>
                    <xs:documentation>Group money purchase</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="28">
                <xs:annotation>
                    <xs:documentation>AVC final salary</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="29">
                <xs:annotation>
                    <xs:documentation>AVC group money purchase</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="30">
                <xs:annotation>
                    <xs:documentation>Self Invested Personal Pensions (SIPPs)</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="99">
                <xs:annotation>
                    <xs:documentation>Other. Use this when product is not one of above.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="RetailInvestmentStructure">
        <xs:sequence>
            <xs:element name="PrincipalOrNetworkFSARef" type="cmn:FSARefType" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>This field only applies if the sale has been made by an intermediary who has a principal or is part of a network. </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="TypePolicy" type="TypeOfPolicyType">
                <xs:annotation>
                    <xs:documentation>Type of policy.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="AdvisedSale" type="cmn:YNType" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>This field is optional until July 2006, when it will become mandatory.  Y = Sale was Advised, N = Sale was non-Advised. For PSD reporting purposes non-Advised includes execution only and direct offer transactions.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="CustPostCode" type="cmn:PostCodeType" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Full U.K postcode of customer.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="PremPaymentMethod" type="cmn:PremiumPaymentMethodType">
                <xs:annotation>
                    <xs:documentation>Method of premium/ contribution payment.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="TotalPremAmt" type="cmn:HSFStdSterlingAmountType">
                <xs:annotation>
                    <xs:documentation>Total premium/contribution amount. Annualised amount rounded to nearest pound.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="CustDOB" type="xs:date" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Date of birth of customer. Applies to first named customer at time of sale i.e. age obtained at proposal stage. Must represent an age up to and including 115.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="DateInForce" type="xs:date"/>
        </xs:sequence>
    </xs:complexType>

    <xs:element name="FSAHSFFeedRI">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="cmn:FSAFeedHeader"/>
                <xs:element name="FSAHSFFeedRIMsg" minOccurs="0" maxOccurs="unbounded">
                    <xs:annotation>
                        <xs:documentation>Defines the inidividual transactions</xs:documentation>
                    </xs:annotation>
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element ref="cmn:CoreItems"/>
                            <xs:element name="RetailInvestment" type="RetailInvestmentStructure">
                                <xs:annotation>
                                    <xs:documentation>Defines the elements that are specific to a Retail Investment transaction.</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

When importing the schema there is an error importing the common feed due to a dead link referenced in the schema:

SchemaLocation="https://gabriel.fca.org.uk/specifications/MER/DRG/PSD-CommonTypes/v1.2/FSAFeedCommon-v1-2.xsd

This can be downloaded separately from the FCA resources section and the schema can be edited to point to the file locally. See below:

<?xml version="1.0" encoding="utf-8"?>

<xs:schema xmlns="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
    elementFormDefault="qualified"
    version="1.2"
    id="FSAFeedCommon-v1-2">

    <xs:simpleType name="NonEmptyString">
        <xs:annotation>
            <xs:documentation>Defines a string type that may not be the empty string. Values of this type are also whitespace normalized meaning all-whitespace strings are also invalid.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:whiteSpace value="collapse"/>
            <xs:minLength value="1"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="FSARefType">
        <xs:annotation>
            <xs:documentation>FSA Reference Number. Either a 6 or 7 digit number.  Leading zeroes are not expected.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="[1-9]{1}[0-9]{5,6}"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="PostCodeType">
        <xs:annotation>
            <xs:documentation>Full or abbreviated UK postcode.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:maxLength value="8"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="YNType">
        <xs:annotation>
            <xs:documentation>Y or N</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="Y"/>
            <xs:enumeration value="N"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="HSFStdSterlingAmountType">
        <xs:annotation>
            <xs:documentation>Integer from 1 to 999999999. Representing sterling-equivalent amount.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:positiveInteger">
            <xs:totalDigits value="9"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="PremiumPaymentMethodType">
        <xs:annotation>
            <xs:documentation>Method of Premium/Contribution payment. Single or Regular.</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:enumeration value="S">
                <xs:annotation>
                    <xs:documentation>Single payment.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="R">
                <xs:annotation>
                    <xs:documentation>Regular payment.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="CoreItems">
        <xs:annotation>
            <xs:documentation>Defines the elements that are common to all transactions.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="FirmFSARef" type="FSARefType">
                    <xs:annotation>
                        <xs:documentation>The FSA code of the reporting firm for this transaction.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="TransRef">
                    <xs:annotation>
                        <xs:documentation>The unique reference, internal to the reporting firm, that will enable the firm to provide the FSA with more information concerning the trade if required. This reference must be unique within each report file, with the exception that a reference can occur twice if one occurrence is a cancellation. </xs:documentation>
                    </xs:annotation>
                    <xs:simpleType>
                        <xs:restriction base="NonEmptyString">
                            <xs:maxLength value="25"/>
                        </xs:restriction>
                    </xs:simpleType>
                </xs:element>
                <xs:element name="Cancellation" type="xs:boolean" minOccurs="0">
                    <xs:annotation>
                        <xs:documentation>Indicates if the transaction is a cancellation. If ommitted this is logically the same as providing a value of 'false'.</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="FSAFeedHeader">
        <xs:annotation>
            <xs:documentation>Defines the report header, common to all reports.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="FeedTargetSchemaVersion" type="xs:string">
                    <xs:annotation>
                        <xs:documentation>Identifies the version of the business specific schema to which this report conforms.</xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="Submitter">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="SubmittingFirm" type="FSARefType">
                                <xs:annotation>
                                    <xs:documentation>The FSA code of the firm submitting the report.</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                            <xs:element name="SubmittingDept" minOccurs="0">
                                <xs:annotation>
                                    <xs:documentation>The identifier of the department within the submitting firm who created this report - optional.</xs:documentation>
                                </xs:annotation>
                                <xs:simpleType>
                                    <xs:restriction base="NonEmptyString">
                                        <xs:maxLength value="20"/>
                                        <xs:pattern value="[a-zA-Z0-9]+"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="ReportDetails">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="ReportCreationDate" type="xs:date">
                                <xs:annotation>
                                    <xs:documentation>Report creation date.</xs:documentation>
                                </xs:annotation>
                            </xs:element>
                            <xs:element name="ReportIdentifier">
                                <xs:annotation>
                                    <xs:documentation>Unique identifier for the report (wthin the context of the submitter, submitting firm, submitting department and report creation date).</xs:documentation>
                                </xs:annotation>
                                <xs:simpleType>
                                    <xs:restriction base="NonEmptyString">
                                        <xs:maxLength value="25"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Resources:

https://regdata.fca.org.uk/specifications/DRG/PSD002/v1.5/FSAHSFFeedRI-v1-3.xsd - Full Schema

https://regdata.fca.org.uk/specifications/DRG/PSD-CommonTypes/v1.2/FSAFeedCommon-v1-2.xsd - Schema referenced using a dead link

https://regdata.fca.org.uk/#/layout/resources - General Resources

Body:
I'm not sure what your question is exactly. You point to 2 problems:

"denormalized data error": what do you mean? how is this related to the schema?

The broken link in the main schema file. You solved it yourself by editing the schemaLocation in the main schema. If you need a way to automatically correct the location without editing the main schema file, you can use an XML Catalog. Is it what you're looking for?

What do you mean also by "importing" the schema? Are you importing it in your own schema?

A catalog would look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <uri name="http://www.fsa.gov.uk/XMLSchema/FSAFeedCommon-v1-2"
  uri="path/to/local/copy/of/FSAFeedCommon-v1-2.xsd"/>
</catalog>

Then, you need to configure your parser (validation tool) to use that catalog.


问:
ASP.NET web package deployment security
We don't want our client to share or misuse the deployed asp.net MVC package to other IIS server machines. we need the asp.net MVC package to only work on specific server machines.</p>

答:
I think in cases like this, the best approach is to include in the contract with your client these types of limitations. Something like "This software can only be used on the specified machines". But consult with a legal team if you can.

Otherwise, you can look into "Licensing Servers". You can try to build your own, but it's hard to develop and maintain the server infrastructure. As an alternative, you can check licensing as a Service. I know of https://keygen.sh/, but I believe there are others.

Title: ASP.NET web package deployment security


问:
Why do I get 0 when running my "mult(num)" function?
I am a noob in Python and I got stuck with the following code. I can't figure out why my function 'mult(num') can't calculate sum 'su' even though inside the function when I run print(su, end="   ") it gives all numbers I expect?

```<code>def mult(num):
    su = 0
    for i in range(num):
        if i % 3 == 0 or i % 5 == 0:
            su += i
            return su
            # print(su, end="   ")  when running this line I see >>>> 0   3   8   14   23   33   45   60

print(mult(18))
</code>```

output

```<code>>>>  0
</code>```

Why do I get 0?

答:
When you execute return su you exit the function. You quit on the first iteration of the loop, so the answer is 0.

Fixed code:

def mult(num):
    su = 0
    for i in range(num):
        if i % 3 == 0 or i % 5 == 0:
            su += i
            #return su

    return su

print(mult(18))

```

Body:
I am a noob in Python and I got stuck with the following code. I can't figure out why my function 'mult(num') can't calculate sum 'su' even though inside the function when I run print(su, end="   ") it gives all numbers I expect?

def mult(num):
    su = 0
    for i in range(num):
        if i % 3 == 0 or i % 5 == 0:
            su += i
            return su
            # print(su, end="   ")  when running this line I see >>>> 0   3   8   14   23   33   45   60

print(mult(18))

output

>>>  0

Why do I get 0?


问:
What is the preferred way to develop a Python package without using setup.py?
I am developing a Python package, and I don't want to have to keep running pip install . to reinstall my package every time I change something. Using the -e or --editable doesn't seem to work unless I have a setup.py file, nor does --no-use-pep517. I have a pyproject.toml instead, as is preferred nowadays if I am not mistaken. So, what is the preferred way to do this nowadays?

My package is just a CLI script, but it imports some functions from another file in the same directory called utils.py. When developing, I can't just run the script manually from the terminal, because then I get "name_of_package is not a package" from the line from name_of_package.utils import function. Whereas if I just have from utils import function, I can run the script from the terminal, but when I pip install it, it says "there is no module named utils".

I did install poetry and installed my dependencies, ran poetry shell and then tried to run my script with poetry run /path/to/script.py, but I kept getting an error that my package wasn't a package.

答:
Nowadays, with setuptools as a build back-end you have the choice of using setup.py, setup.cfg, pyproject.toml, or any combination of these three files to declare the project's metadata and configure the project's packaging. With pyproject.toml being the preferred one as it is standardized (see below). All these are compatible with editable installation (python -m pip install --editable .).

The editable installation mechanism has a standard specification (initiated by the PEP 660 document). And many build back-ends besides setuptools support it. These are the build back-ends I know of that support the standardized editable installation mechanism:

enscons

flit-core (see flit)

hatchling (see hatch)

maturin

meson-python

pdm-backend (see pdm)

poetry-core (see poetry)

setuptools

whey

All these build back-ends can have their configuration in pyproject.toml (including support for the standardized [build-system] section, aka PEP 517), and all but Poetry support the standardized [project] section (aka PEP 621). I have a comparison table here.


问:
React: how to use onclick function in a loop in class component?
what i want is to run an onClick event handler in a loop.
what i have done is :

my component looks something like this.

```<code>import React, { Component } from "react";
import Link from 'next/link';

class VehicleSpecifications extends Component {

constructor(props) {
super(props);
this.setActiveClass = this.setActiveClass.bind(this)

this.state = {
    tabStatus: "",
};
}

setActiveClass = (e) => {
  console.log(e)
}

render() {
const vehicleSpecs = this.props.vehicleSpecs;
console.log(this.props.vehicleSpecs)
return (
  <React.Fragment>
    <div className="vertical-tabs" >
      <ul className="nav nav-tabs" role="tablist">
        {
          Object.entries(vehicleSpecs).map(function (items, car_index) {
            let typeAndName = items[0].split(':-:');
            return (
              <li className="nav-item"   onClick={ ()=> setActiveClass("#pag") }>
                <Link
                  className="nav-link active"
                  data-toggle="tab"
                  href={"#pag" + car_index}
                  role="tab"
                  aria-controls="performance">
                  {typeAndName[0].replace('_', ' ').toUpperCase()}

                </Link>
              </li>
            )
          })
        }
      </ul>

    </div>
  </React.Fragment>
);
}
}
</code>```

export default VehicleSpecifications;

i have tried things but this onclick function sometime gives _this is undefined or says function is undefined.

答: You're in a class component, so onClick={ () => this.setActiveClass("#pag") } otherwise setActiveClass is not defined in render scope

Body:
what i want is to run an onClick event handler in a loop.
what i have done is :

my component looks something like this.

import React, { Component } from "react";
import Link from 'next/link';

class VehicleSpecifications extends Component {

constructor(props) {
super(props);
this.setActiveClass = this.setActiveClass.bind(this)

this.state = {
    tabStatus: "",
};
}

setActiveClass = (e) => {
  console.log(e)
}

render() {
const vehicleSpecs = this.props.vehicleSpecs;
console.log(this.props.vehicleSpecs)
return (
  <React.Fragment>

        {
          Object.entries(vehicleSpecs).map(function (items, car_index) {
            let typeAndName = items[0].split(':-:');
            return (

 setActiveClass("#pag") }>
                <Link
                  className="nav-link active"
                  data-toggle="tab"
                  href={"#pag" + car_index}
                  role="tab"
                  aria-controls="performance">
                  {typeAndName[0].replace('_', ' ').toUpperCase()}

                </Link>

            )
          })
        }

  </React.Fragment>
);
}
}

export default VehicleSpecifications;

i have tried things but this onclick function sometime gives _this is undefined or says function is undefined.


问:
Invalid query. You cannot use more than one 'in' filter
```<code>this.ref.collection("users", ref => ref.where("uid1","in", [reciverId, senderId])
        .where("uid2","in", [reciverId, senderId]))
</code>```

give me error like

"Invalid query. You cannot use more than one 'in' filter"

答:
```<code> this.messages_collection = this.afs.collection<ChatMessage>('messages',
  ref => ref.where('email', 'in', [this.user.email, this.receiver.email])
    .where('receiver_email', 'in', [this.user.email, this.receiver.email])
    .orderBy('timesent')
);`enter code here`
</code>```

Body:
this.ref.collection("users", ref => ref.where("uid1","in", [reciverId, senderId])
        .where("uid2","in", [reciverId, senderId]))

give me error like

"Invalid query. You cannot use more than one 'in' filter"


问:
Angular Material DatePicker not Changing when Moment locale does
Details: Angular Material 7 DatePicker with moment js

Problem: When the language of my web application is changed, the datepickers do not change locale.

Desired result: Every time I change the language in my application, my date pickers should also change to that locales format and language. At the moment, I need to toggle between dd/MM/yyyy and MM/dd/yyyy.

Could anyone point me in the right direction? I am new to moment and cannot seem to get the formatting done properly.

Code:

HTML

```<code><mat-form-field>
  <mat-label>From date</mat-label>
  <input name="fromDate" [min]="minDate" [max]="maxDate" [formControl]="displayFromDate"
                     matInput [matDatepicker]="fromDatePicker">
  <mat-datepicker-toggle matSuffix [for]="fromDatePicker"></mat-datepicker-toggle>
  <mat-datepicker #fromDatePicker disabled="false"></mat-datepicker>
</mat-form-field>
</code>```

Some of my translation service code that changes the moment locale:
the lang parameter will either be 'en' or 'fr' and is toggled by a switch that the app is listening to.

```<code>public use(lang: string): void {
  this._currentLang = lang;
  moment.locale(lang);
  this.currentLang$.next(this.currentLang);
}
</code>```

App.module.ts

```<code>import { MAT_MOMENT_DATE_FORMATS, MomentDateAdapter } from '@angular/material-moment-adapter';

import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';

import localeFr from '@angular/common/locales/fr';
import localeEn from '@angular/common/locales/en';

registerLocaleData(localeFr);
registerLocaleData(localeEn);
</code>```

...

```<code>imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
</code>```

...

```<code>{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS },],
</code>```

Component code using the datepicker:

```<code>this.translationService.currentLang$.subscribe(currentLang => {
  this.displayFromDate = new FormControl({ value: moment(this.displayFromDate.value).format(), disabled: true });
  console.log('displayFromDate', this.displayFromDate);
});
</code>```

答:
You can call moment.tz.guess() with an optional boolean argument "ignoreCache". If set to true, the cache will be ignored and overwritten with the new value.

Moment doc URL - https://momentjs.com/timezone/docs/#/using-timezones/guessing-user-timezone/

Working example - https://codesandbox.io/s/material-date-locale-jyylz

Body:
Details: Angular Material 7 DatePicker with moment js

Problem: When the language of my web application is changed, the datepickers do not change locale.

Desired result: Every time I change the language in my application, my date pickers should also change to that locales format and language. At the moment, I need to toggle between dd/MM/yyyy and MM/dd/yyyy.

Could anyone point me in the right direction? I am new to moment and cannot seem to get the formatting done properly.

Code:

HTML

<mat-form-field>
  <mat-label>From date</mat-label>
  <input name="fromDate" [min]="minDate" [max]="maxDate" [formControl]="displayFromDate"
                     matInput [matDatepicker]="fromDatePicker">
  <mat-datepicker-toggle matSuffix [for]="fromDatePicker"></mat-datepicker-toggle>
  <mat-datepicker #fromDatePicker disabled="false"></mat-datepicker>
</mat-form-field>

Some of my translation service code that changes the moment locale:
the lang parameter will either be 'en' or 'fr' and is toggled by a switch that the app is listening to.

public use(lang: string): void {
  this._currentLang = lang;
  moment.locale(lang);
  this.currentLang$.next(this.currentLang);
}

App.module.ts

import { MAT_MOMENT_DATE_FORMATS, MomentDateAdapter } from '@angular/material-moment-adapter';

import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';

import localeFr from '@angular/common/locales/fr';
import localeEn from '@angular/common/locales/en';

registerLocaleData(localeFr);
registerLocaleData(localeEn);

...

imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,

...

{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS },],

Component code using the datepicker:

this.translationService.currentLang$.subscribe(currentLang => {
  this.displayFromDate = new FormControl({ value: moment(this.displayFromDate.value).format(), disabled: true });
  console.log('displayFromDate', this.displayFromDate);
});


问:
How does static field initialization work in C#?
Should static field initialization be completed before constructor is called?

The following program provides output that seems incorrect to me.

```<code>new A()
_A == null
static A()
new A()
_A == A
</code>```

The code:

```<code>public class A
{
    public static string _A = (new A()).I();

    public A()
    {
        Console.WriteLine("new A()");
        if (_A == null)
            Console.WriteLine("_A == null");
        else
            Console.WriteLine("_A == " + _A);
    }

    static A()
    {
        Console.WriteLine("static A()");
    }

    public string I()
    {
        return "A";
    }
}

class Program
{
    static void Main(string[] args)
    {
       var a = new A();
    }
}
</code>```

答:
This is correct.

Your static initializers, then the static constructor is run before your standard constructor, but when it runs, it's using new A(), so passing through your non-static constructor path.  This causes the messages you see.

Here is the full path of execution:

When you first call var a = new A(); in your program, this is the first time A is accessed.

This will fire off the static initialization of A._A

At this point, A._A constructs with _A = (new A()).I();

This hits

```<code>
Console.WriteLine("new A()");
if (_A == null)
    Console.WriteLine("_A == null");
</code>```

since at this point, _A hasn't been set with the returned, constructed type (yet).

Next, the static constructor A { static A(); } is run.  This prints the "static A()" message.

Finally, your original statement (var a = new A();) is executed, but at this point, the statics are constructed, so you get the final print.

ContentLicense: CC BY-SA 2.5

Body:
Should static field initialization be completed before constructor is called?

The following program provides output that seems incorrect to me.

new A()
_A == null
static A()
new A()
_A == A

The code:

public class A
{
    public static string _A = (new A()).I();

    public A()
    {
        Console.WriteLine("new A()");
        if (_A == null)
            Console.WriteLine("_A == null");
        else
            Console.WriteLine("_A == " + _A);
    }

    static A()
    {
        Console.WriteLine("static A()");
    }

    public string I()
    {
        return "A";
    }
}

class Program
{
    static void Main(string[] args)
    {
       var a = new A();
    }
}

Body:
This is correct.

Your static initializers, then the static constructor is run before your standard constructor, but when it runs, it's using new A(), so passing through your non-static constructor path.  This causes the messages you see.

Here is the full path of execution:

When you first call var a = new A(); in your program, this is the first time A is accessed.

This will fire off the static initialization of A._A

At this point, A._A constructs with _A = (new A()).I();

This hits

Console.WriteLine("new A()");
if (_A == null)
    Console.WriteLine("_A == null");

since at this point, _A hasn't been set with the returned, constructed type (yet).

Next, the static constructor A { static A(); } is run.  This prints the "static A()" message.

Finally, your original statement (var a = new A();) is executed, but at this point, the statics are constructed, so you get the final print.

OwnerDisplayName: Reed Copsey

LastEditorDisplayName: Reed Copsey


问:
Netbeans JDBC Error "Unable to find suitable driver" after JDK update
I recently upgraded my jdk from 6 to 8 when I installed Eclispe for Android. Now, in NetBeans when I try to right click on the node for the database and select connect, I get the following error:

"Unable to connect. Cannot establish a connection to jdbc:derby://localhost 1527:/Animal using org.apache.derby.jdbc.ClientDriver (Unable to find a suitable driver)."

So far, I have tried uninstalling Eclipse and reinstalling Netbeans and that didn't work. I'm not getting any errors in my code aside from a popup that says the project is missing resources. Could someone please provide instructions on how to  solve this issue? I've looked on the NetBeans' website and on this forum and there doesn't seem to be a clear procedure for resolving this.

答:
I had the same problem when trying to connect MySQL server to NetbeansIDE. Turns out the jdbc connector was an old version. You can read about the MySQL connector versions here. Either

download the latest version of MySQL connector or

add a new driver.

My problem was solved by adding a new driver.

ContentLicense: CC BY-SA 3.0


问:
Enable mat button only on object change
I have a mat-toggle-button which I would like to make clickable only when an object in the ts class is changed, otherwise it should stay greyed out

<mat-button-toggle (click)="updateChanges()"  appearance="fill">Update changes</mat-button-toggle>

I thought of using the SimpleChanges API for this as it tracks status changes on a registered object (ideal for my case).

```<code>@Input() myObject: MyObject;
public updateButtonClickable: boolean = false;
 ngOnChanges(changes: SimpleChanges) {
        if (changes.myObject) {
            this.updateButtonClickable = true;
        } else {
            this.updateButtonClickable = false;
        }
    }
</code>```

The first problem is that this approach detects changes at page loading, so my boolean flag variable will be set to true when the page loads, annoying as i would not define this a status change.

Now my second issue is to bind the button status to this variable value, i have been looking at the material page but i dont see the way how I could achive this, any idea?

答:
We could compare if we have previousValue. And if previousValue is not the same as currentValue then it must be a new obj. We use [disabled] to "gray out" and make the button not clickable if updateButtonClickable boolean is false.

@Component({
  selector: 'hello',
  template: `
Complex: {{ complex | json }}

  <button [disabled]="!updateButtonClickable">I am button</button>

`,
})
export class HelloComponent implements OnChanges {
  @Input() myObject: any;
  public updateButtonClickable: boolean = false;

  ngOnChanges(changes: SimpleChanges) {
    if (changes.myObject) {
      console.log(changes);
      if (
        changes.myObject.previousValue != undefined &&
        changes.myObject.previousValue != changes.myObject.currentValue
      ) {
        console.log('yes now enable');
        this.updateButtonClickable = true;
      } else {
        this.updateButtonClickable = false;
      }
    }
  }
}
```

Here is a working example: https://stackblitz.com/edit/angular-ng-on-changes-example-v44p6v?file=src%2Fapp%2Fhello.component.ts

Title: Enable mat button only on object change

Body:
I have a mat-toggle-button which I would like to make clickable only when an object in the ts class is changed, otherwise it should stay greyed out

<mat-button-toggle (click)="updateChanges()"  appearance="fill">Update changes</mat-button-toggle>

I thought of using the SimpleChanges API for this as it tracks status changes on a registered object (ideal for my case).

@Input() myObject: MyObject;
public updateButtonClickable: boolean = false;
 ngOnChanges(changes: SimpleChanges) {
        if (changes.myObject) {
            this.updateButtonClickable = true;
        } else {
            this.updateButtonClickable = false;
        }
    }

The first problem is that this approach detects changes at page loading, so my boolean flag variable will be set to true when the page loads, annoying as i would not define this a status change.

Now my second issue is to bind the button status to this variable value, i have been looking at the material page but i dont see the way how I could achive this, any idea?

Body:
We could compare if we have previousValue. And if previousValue is not the same as currentValue then it must be a new obj. We use [disabled] to "gray out" and make the button not clickable if updateButtonClickable boolean is false.

@Component({
  selector: 'hello',
  template: `<p>Complex: {{ complex | json }}</p><br>
  <button [disabled]="!updateButtonClickable">I am button</button>
  <br>
  <br>`,
})
export class HelloComponent implements OnChanges {
  @Input() myObject: any;
  public updateButtonClickable: boolean = false;

  ngOnChanges(changes: SimpleChanges) {
    if (changes.myObject) {
      console.log(changes);
      if (
        changes.myObject.previousValue != undefined &&
        changes.myObject.previousValue != changes.myObject.currentValue
      ) {
        console.log('yes now enable');
        this.updateButtonClickable = true;
      } else {
        this.updateButtonClickable = false;
      }
    }
  }
}

Here is a working example: https://stackblitz.com/edit/angular-ng-on-changes-example-v44p6v?file=src%2Fapp%2Fhello.component.ts


问:
How should I share API definitions between the server and the client, both in TypeScript?
I've got a server (TypeScript, NestJS) and a client (TypeScript, Angular) and they talk to each other.

Currently I have the API repsonse DTO classes defined in the server to output, and again in the client to decode the responses into a class. This smells.

What's a good way to share the API response DTOs between the two projects (or, if this isn't a good idea, why)?

Ideally, I'd like to be able to change the API response format for the server, and then have the client not build because things have changed. It's still in very early beta at the moment, and I control deployment of both client and server so a fair amount of these changes are breaking.

They're currently in two git repositories, but if needed that can change.

答:
You have several options to achieve this - but they need you to think about the structure of the project (and need some work).

Using the monorepo approach, by utilizing tools such as NX (here's a getting started), you can have your types/models in one place and share them between your frontend and backend. There's also other tools such as Turborepo

Another way would be to make a shared repository of types and share them between both your backend and frontend using git submodules.


问:
How to call rest API in the loop
I want to call the third party API multiple times using the RestTemplate(for each customer id I have to call REST API) currently I have written like below and its working fine but it's taking time because there are many customers I'd and calling API for each customer id, is there any way I can make this parallel.</p>
```<code> public List<Organization> getCustomeOrganizationInfo(){
   String url="https://url.net/core/v1/customers"
   List<Organization> organizationList = new ArrayList<>();

    for(Customer customer:CustomerList){

      String restUrlWithUserId=url+"/customer.getCustomerId"

        CustomerInfo customerInfo = restTemplate.exchange(
                restUrlWithUserId,
                HttpMethod.GET,
                request,
                String.class
        );

    Organization organization =new Organization();
    organization.setCustomerId(customer.getCustomerId())
    organization.setorganizationId(customerInfo.getCustomeOrganizationId())
    organization.setorganizationname(customerInfo.getCustomeOrganizationName())

   organizationList.add(organization)
}

}
</code>```

答:
Is there any way I can make this parallel

For concurrency and clean code, you should separate your restTemplate call to another class(service), for example, ThirdPartyCustomerService.java. This class will be held responsible for calling outside.

@Service
public class ThirdPartyCustomerService {
   private final RestTemplate restTemplate;
   private final String url = '...';
   ...
   public CustomerInfo getCustomerInfo() {
       return this.restTemplate...
   }
}
```
<p>Then you can inject this class into your service class. Now if you want to run it concurrency. You could try <code>@Async</code> and <code>Future</code> here. Just need a little bit of change on the new service and remember to call Future.get() on your main service.</p>
<pre class="lang-java prettyprint-override"><code>@Async
public Future<CustomerInfo> getCustomerInfo() {
   return new AsyncResult<CustomerInfo>(this.restTemplate...);
}
</code>```

Or you can use WebClient, an alternative for RestTemplate and AsyncRestTemplate.

Title: How to call rest API in the loop

Body:
I want to call the third party API multiple times using the RestTemplate(for each customer id I have to call REST API) currently I have written like below and its working fine but it's taking time because there are many customers I'd and calling API for each customer id, is there any way I can make this parallel.

 public List<Organization> getCustomeOrganizationInfo(){
   String url="https://url.net/core/v1/customers"
   List<Organization> organizationList = new ArrayList<>();

    for(Customer customer:CustomerList){

      String restUrlWithUserId=url+"/customer.getCustomerId"

        CustomerInfo customerInfo = restTemplate.exchange(
                restUrlWithUserId,
                HttpMethod.GET,
                request,
                String.class
        );

    Organization organization =new Organization();
    organization.setCustomerId(customer.getCustomerId())
    organization.setorganizationId(customerInfo.getCustomeOrganizationId())
    organization.setorganizationname(customerInfo.getCustomeOrganizationName())

   organizationList.add(organization)
}

}

Body:
Is there any way I can make this parallel

For concurrency and clean code, you should separate your restTemplate call to another class(service), for example, ThirdPartyCustomerService.java. This class will be held responsible for calling outside.

@Service
public class ThirdPartyCustomerService {
   private final RestTemplate restTemplate;
   private final String url = '...';
   ...
   public CustomerInfo getCustomerInfo() {
       return this.restTemplate...
   }
}

Then you can inject this class into your service class. Now if you want to run it concurrency. You could try @Async and Future here. Just need a little bit of change on the new service and remember to call Future.get() on your main service.

@Async
public Future<CustomerInfo> getCustomerInfo() {
   return new AsyncResult<CustomerInfo>(this.restTemplate...);
}

Or you can use WebClient, an alternative for RestTemplate and AsyncRestTemplate.


问:
VSCode extension: Custom Editor with Webview both on typescript
I need to create VSCode extension. There should be Custom Editor with Webview. Also I need to use shared code in Custom Editor and Webview. Plus I need to use some libs so I plan to use webpack. yo code can generate extension skeleton with typescript and webpack. But I can't generate file for Webview.

答:
First create a production build with webpack. This serves as the content for your webview. But because it is not possible to load the webview from an URL directly, you have to insert an iframe and load that from the URL instead.

    protected createPanel(caption: string, url: URL, placement?: string): Promise<boolean> {
        return new Promise((resolve) => {
            const viewColumn = (!placement || placement === "Active") ? ViewColumn.Active : ViewColumn.Beside;
            if (placement === "Beside Bottom") {
                void commands.executeCommand("workbench.action.editorLayoutTwoRows");
            }

            this.panel = window.createWebviewPanel(
                "the-webview", caption, viewColumn, {
                    enableScripts: true,
                    retainContextWhenHidden: true,
                },
            );

            this.panel.onDidDispose(() => { this.handleDispose(); });

            this.panel.webview.onDidReceiveMessage((message: IEmbeddedMessage) => {
                if (message.source === "app") {
                    // Handle webview messages here.
                }
            });

            // Insert an iframe to load the external URL.
            this.panel.webview.html = `
    <!doctype html>

    <meta http-equiv="Content-Security-Policy" content="default-src *; img-src http: https:;
        script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline' http: https: data: *;">

    `;

        });
    }

```

The webview itself is also an iframe, but message handling between that and vscode is already in place. However for that additional iframe you have to do something similar to forward message either from your app code to vscode or the other direction. In my code I use a field in the sent data to decide which direction I have to take.

Body:
First create a production build with webpack. This serves as the content for your webview. But because it is not possible to load the webview from an URL directly, you have to insert an iframe and load that from the URL instead.

    protected createPanel(caption: string, url: URL, placement?: string): Promise<boolean> {
        return new Promise((resolve) => {
            const viewColumn = (!placement || placement === "Active") ? ViewColumn.Active : ViewColumn.Beside;
            if (placement === "Beside Bottom") {
                void commands.executeCommand("workbench.action.editorLayoutTwoRows");
            }

            this.panel = window.createWebviewPanel(
                "the-webview", caption, viewColumn, {
                    enableScripts: true,
                    retainContextWhenHidden: true,
                },
            );

            this.panel.onDidDispose(() => { this.handleDispose(); });

            this.panel.webview.onDidReceiveMessage((message: IEmbeddedMessage) => {
                if (message.source === "app") {
                    // Handle webview messages here.
                }
            });

            // Insert an iframe to load the external URL.
            this.panel.webview.html = `
    <!doctype html><html lang="en">
    <head>
    <meta http-equiv="Content-Security-Policy" content="default-src *; img-src http: https:;
        script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'unsafe-inline' http: https: data: *;">
    </head>
    <body style="margin:0px;padding:0px;overflow:hidden;">
    <iframe id="frame:${caption}"
        src="${url.toString()}"
        frameborder="0" style="overflow: hidden; overflow-x: hidden; overflow-y: hidden; height:100%;
        width:100%; position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px" height="100%"
        width="100%">
    </iframe>
    <script>
        let frame;
        let vscode;

        window.addEventListener('message', (event) => {
            if (!frame) {
                vscode = acquireVsCodeApi();
                frame = document.getElementById("frame:${caption}");
            }

            if (event.data.source === "host") {
                // Forward message from the extension to the iframe.
                frame.contentWindow.postMessage(event.data, "*");
            } else if (event.data.source === "app") {
                // Forward messages from the iframe to the extension.
                vscode.postMessage(event.data);
            } else {
                // Forward certain messages to our parent window, which will further forward to vscode.
                switch (event.data.type) {
                    case "keydown": {
                        window.dispatchEvent(new KeyboardEvent("keydown", event.data));
                        break;
                    }
                    case "keyup": {
                        window.dispatchEvent(new KeyboardEvent("keyup", event.data));
                        break;
                    }
                }
            }
        });
    </script>

    </body></html>
    `;

        });
    }

The webview itself is also an iframe, but message handling between that and vscode is already in place. However for that additional iframe you have to do something similar to forward message either from your app code to vscode or the other direction. In my code I use a field in the sent data to decide which direction I have to take.


问:
Ambiguous Call when using Should().NotBeNull() on As item
When I do the following test

```<code>var contentRes = res as OkNegotiatedContentResult<List<MachineHealthTableDTO>>;
contentRes.Should().NotBeNull();
</code>```

I get the error

```<code>The call is ambiguous between the following methods or properties: 'DataRowAssertionExtensions.Should<TDataRow>(TDataRow)' and 'DataSetAssertionExtensions.Should<TDataSet>(TDataSet)'
</code>```

This started happening when I upgraded from fluent assertions 5 to 6.
Any Idea as to how I can go about resolving this issue would be appreciated.

答:
I had a very similar issue with an enum

```<code>actualEnumValue.Should().Be(expectedEnumValue);
</code>```

with the error

Error CS0121  The call is ambiguous between the following methods or properties: 'DataRowAssertionExtensions.Should(TDataRow)' and 'DataSetAssertionExtensions.Should(TDataSet)'

I finally managed to solve the issue by removing <LangVersion>7</LangVersion> from the project file.

Body:
When I do the following test

var contentRes = res as OkNegotiatedContentResult<List<MachineHealthTableDTO>>;
contentRes.Should().NotBeNull();

I get the error

The call is ambiguous between the following methods or properties: 'DataRowAssertionExtensions.Should<TDataRow>(TDataRow)' and 'DataSetAssertionExtensions.Should<TDataSet>(TDataSet)'

This started happening when I upgraded from fluent assertions 5 to 6.
Any Idea as to how I can go about resolving this issue would be appreciated.

Body:
I had a very similar issue with an enum

actualEnumValue.Should().Be(expectedEnumValue);

with the error

Error CS0121  The call is ambiguous between the following methods or properties: 'DataRowAssertionExtensions.Should(TDataRow)' and 'DataSetAssertionExtensions.Should(TDataSet)'

I finally managed to solve the issue by removing <LangVersion>7</LangVersion> from the project file.


问:
Communicate with Kohler Meter in C#
I m trying to communicate with Kohler active meter. It s half duplex. I ve read all protocol. Kohler has own software to see the profiles. While it was reading the profiles, i tried to view how it is happening. Sending and recieving datas. Then i tried to write a programme in C#. To communicate in first steps baud-rate is chosen 300, and then it should be 4800.

Here is my problems:

If i try to debug my programme using F5, it is not communicating. But if i use step into mode F11, it is working? i guess it should wait some amount of time. any idea?

When i try to change baud-rate from 300 to 4800, step into mode F11 is not working. I checked in the software if it is changing or not, but it is fine. any idea what this is about?

答:
Before sending your requests wait for some time . When you debug with F5 you don't wait. But with F11 you wait unavoidablely. This also shows that your program works better when you wait :)  Use a monitoring program like 'Free Serial Port Monitor' to find out these waiting times by first running Kohler's own program.

You can use a streamreader and streamwriter to communicate with the meter.
Like

```<code> writer = new StreamWriter(((System.IO.Ports.SerialPort)serialPort).BaseStream);
 reader = new StreamReader(((System.IO.Ports.SerialPort)serialPort).BaseStream);
</code>```

Don't forget to use writer.Flush() command just after you user write command.
To wait sometimes before you send your commands to the meter use  System.Threading.Thread.Sleep(250); code . 250 is in msecs.
I don't recommend you to wait after sending the request. Wait before you send the new request, ACK message, etc.
If kohler's own program waits too much between commands set serialports timeout values ...

```<code>(serialport).ReadTimeout = xxx;
(serialport).WriteTimeout = xxx;
</code>```

Title: Communicate with Kohler Meter in C#

Body:
Before sending your requests wait for some time . When you debug with F5 you don't wait. But with F11 you wait unavoidablely. This also shows that your program works better when you wait :)  Use a monitoring program like 'Free Serial Port Monitor' to find out these waiting times by first running Kohler's own program.

You can use a streamreader and streamwriter to communicate with the meter.
Like

 writer = new StreamWriter(((System.IO.Ports.SerialPort)serialPort).BaseStream);
 reader = new StreamReader(((System.IO.Ports.SerialPort)serialPort).BaseStream);

Don't forget to use writer.Flush() command just after you user write command.
To wait sometimes before you send your commands to the meter use  System.Threading.Thread.Sleep(250); code . 250 is in msecs.
I don't recommend you to wait after sending the request. Wait before you send the new request, ACK message, etc.
If kohler's own program waits too much between commands set serialports timeout values ...

(serialport).ReadTimeout = xxx;
(serialport).WriteTimeout = xxx;