Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1066719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:03:30+00:00 2026-05-16T20:03:30+00:00

I need to analyze a few thousand XML documents to see if some of

  • 0

I need to analyze a few thousand XML documents to see if some of them contains a certain construct. The problem is that some of the documents doesn’t contain well formed XML.

The basic idea was to use fn:collection() and search inside nodes returned. But this only works if all documents in the collection are well formed.

Is it possible to do something similar but only parsing the well formed documents?

This is my XSLT, simplified, which works if all documents in $dir are well formed:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xsl:output method="text"/>
  <xsl:variable name="dir" as="xs:string">file:/c:/path/to/files/</xsl:variable>
  <xsl:variable name="files" select="concat($dir, '?select=*.xml')" as="xs:string"/>

  <xsl:template match="/">
    <xsl:variable name="docs" select="collection($files)"/>
    <xsl:variable name="names" select="
      for $i in $docs return
        distinct-values($i//*[exists(@an-attribute-to-find)]/local-name())"/>
    <xsl:value-of select="distinct-values($names)" separator="&#x0a;"/>
  </xsl:template>

</xsl:stylesheet>

Would it be possible to do something like this without manually sorting out the non well formed documents before transformation starts? Maybe you have a better suggestion to a solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:03:30+00:00Added an answer on May 16, 2026 at 8:03 pm

    At present this is best done out of XSLT.

    It can be done in XSLT if you provide as an exrternal parameter (<xsl:param>) to the transformation a list of all filenames to be processed — then the transformation would use the standard XPath 2.0 function doc-available() and operate only on the document nodes returned by this function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm planning to write a web application (.net probably) that will need to analyze
So for some research work, I need to analyze a ton of raw movement
I'm trying to analyze logs using splunk and I need to parse lines that
I need to write a script for MS Exchange Server 2003 that will analyze
I have a curious problem, I need to analyze a Java heap dump (from
I need to analyze a log for specific output and if a certain keyword
I have a huge file that I need to analyze. What I want to
I have some internet traffic data to analyze. I need to analyze only those
I have two financial graphics and I need to analyze how them perform comparing
I'm working on an ASP.NET project that contains a few hundreds of ASPX/ASCX files,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.