Giter Club home page Giter Club logo

Comments (11)

gustavofonseca avatar gustavofonseca commented on August 27, 2024

Para localizar rapidamente onde está o problema, não seria melhor a indicação do número da linha ao invés de um trecho dela?

from packtools.

lpanebr avatar lpanebr commented on August 27, 2024

Você tem razão que o número da linha é ideal para localizar o erro.

Eu me expressei mal. Eu quis dizer que basta bater o olho para saber *rprobresoema!

from packtools.

lpanebr avatar lpanebr commented on August 27, 2024

Putz.. usar o celular não foi boa idéia. ..

Eu quis dizer que basta bater o olho para saber resolver o problema.

Anyway.. acho que o snippet e o número da linha no xml original atenderá a todos.

from packtools.

gustavofonseca avatar gustavofonseca commented on August 27, 2024

O branch https://github.com/scieloorg/packtools/tree/stylechecker-sourcelines apresenta uma implementação que muda a saída de erros para:

[
  {
    "_xml": "/Users/gustavofonseca/prj/github/packtools/tests/samples/0034-8910-rsp-48-2-0216.xml",
    "assets": [],
    "dtd_errors": [],
    "is_valid": false,
    "sps_errors": [
      {
        "apparent_line": null,
        "message": "Element 'funding-group': This element is not expected."
      },
      {
        "apparent_line": 108,
        "message": "Element 'abstract': Unexpected attribute xml:lang."
      },
      {
        "apparent_line": 26,
        "message": "Element 'article-title': Unexpected attribute xml:lang."
      }
    ]
  }
]

Onde o valor null aparece onde não é possível inferir a linha que contém o erro.

@lpanebr, qual sua impressão sobre essa abordagem?

from packtools.

lpanebr avatar lpanebr commented on August 27, 2024

Legal @gustavofonseca , parabéns pela velocidade! Isso já é muito bom para localizar o erro no XML, principalmente para os prestadores que editam o XML diretamente...

Entretanto, no nosso caso em particular, onde resolvemos o problema no DOC e depois exportamos o XML novamente, o ideal seria ter o snippet da linha que gerou o erro como eu ilustrei. Dessa forma eu bato o olho na linha e já sei onde está o problema no DOC.

from packtools.

gustavofonseca avatar gustavofonseca commented on August 27, 2024

O branch foi atualizado com uma implementação que adiciona o snippet do suposto elemento que apresenta o problema. A saída é algo como:

[
  {
    "_xml": "/Users/gustavofonseca/prj/github/packtools/tests/samples/0034-8910-rsp-48-2-0216.xml",
    "assets": [],
    "dtd_errors": [],
    "is_valid": false,
    "sps_errors": [
      {
        "apparent_line": null,
        "apparent_snippet": null,
        "message": "Element 'funding-group': This element is not expected."
      },
      {
        "apparent_line": 108,
        "apparent_snippet": "<abstract xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:mml=\"http://www.w3.org/1998/Math/MathML\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xml:lang=\"en\"><sec><title>OBJECTIVE</title><p>To estimate the prevalence of depressive symptoms among institutionalized elderly individuals and to analyze factors associated with this condition.</p></sec><sec><title>METHODS</title><p>This was a cross-sectional study involving 462 individuals aged 60 or older, residents in long stay institutions in four Brazilian municipalities. The dependent variable was assessed using the 15-item Geriatric Depression Scale. Poisson\u2019s regression was used to evaluate associations with co-variables. We investigated which variables were most relevant in terms of presence of depressive symptoms within the studied context through factor analysis.</p></sec><sec><title>RESULTS</title><p>Prevalence of depressive symptoms was 48.7%. The variables associated with depressive symptoms were: regular/bad/very bad self-rated health; comorbidities; hospitalizations; and lack of friends in the institution. Five components accounted for 49.2% of total variance of the sample: functioning, social support, sensory deficiency, institutionalization and health conditions. In the factor analysis, functionality and social support were the components which explained a large part of observed variance.</p></sec><sec><title>CONCLUSIONS</title><p>A high prevalence of depressive symptoms, with significant variation in distribution, was observed. Such results emphasize the importance of health conditions and functioning for institutionalized older individuals developing depression. They also point to the importance of providing opportunities for interaction among institutionalized individuals.</p></sec></abstract>",
        "message": "Element 'abstract': Unexpected attribute xml:lang."
      }
    ]
  }
]

O problema é que o snippet tem o potencial de ser o XML completo, no caso do erro ocorrer no elemento raíz. Na minha opinião, essa característica inviabiliza a funcionalidade.

from packtools.

lpanebr avatar lpanebr commented on August 27, 2024

Legal!

Sim, snippets gigantes sem dúvida inviabilizariam mesmo... Caso fosse possível truncar o snippet creio que os primeiros 90-100 caracteres já seriam mais que suficientes para identificar o conteúdo e o problema.

Abaixo a saída simulada. Tomei a liberdade de alterar também a ordem para "apparent_line", "message" e "apparent_snippet" para uma que acho melhor.

[
  {
    "_xml": "/Users/gustavofonseca/prj/github/packtools/tests/samples/0034-8910-rsp-48-2-0216.xml",
    "assets": [],
    "dtd_errors": [],
    "is_valid": false,
    "sps_errors": [
      {
        "apparent_line": null,
        "message": "Element 'funding-group': This element is not expected."
        "apparent_snippet": null,
      },
      {
        "apparent_line": 108,
        "message": "Element 'abstract': Unexpected attribute xml:lang."
        "apparent_snippet": "<abstract xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:mml=\"http://www.w3.org/1998/Math/Math...",
      }
    ]
  }
]

Para ser sincero o erro no abstract não é o melhor para ilustrar a utilidade desta saída pois é um elemento único.. Entretanto, nos casos de footnotes, xrefs e outros elementos onde podem ocorrer muitos erros, será realmente útil olhar o snippet!

from packtools.

gustavofonseca avatar gustavofonseca commented on August 27, 2024

No caso do truncamento, não há garantia de que o trecho errôneo estará na parte preservada. Outro problema potencial é que os elementos são enriquecidos naturalmente pelo parser da libxml2, e passam a apresentar as declarações de namespace inline. Esse fato causará um bocado de desperdício em termos de informação.

from packtools.

lpanebr avatar lpanebr commented on August 27, 2024

ahh..... por isso estava poluída a tag abstract...

que pena.. se não rolar um desenrriquecimento vai ficar bem feio sim..

deixa só como na sua sugestão original então que já vai ajudar!

desculpe a perda de tempo. :-/

from packtools.

gustavofonseca avatar gustavofonseca commented on August 27, 2024

Vou dar uma olhada se consigo melhorar

On 19/02/2015, at 18:40, Luciano [email protected] wrote:

ahh..... por isso estava poluída a tag abstract...

que pena.. se não rolar um desenrriquecimento vai ficar bem feio sim..

deixa só como na sua sugestão original então que já vai ajudar!

desculpe a perda de tempo. :-/


Reply to this email directly or view it on GitHub #26 (comment).

from packtools.

gustavofonseca avatar gustavofonseca commented on August 27, 2024

Por hora, a linha no xml do elemento que supostamente apresenta o erro foi incluída no relatório de saída.

from packtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.