Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] InputStream instead of file #122

Closed
cshjsc opened this issue Nov 24, 2021 · 2 comments
Closed

[question] InputStream instead of file #122

cshjsc opened this issue Nov 24, 2021 · 2 comments
Assignees

Comments

@cshjsc
Copy link

cshjsc commented Nov 24, 2021

Is there a way to make a ISchematronResource out of an Inputstream instead of just a file
I couldn't find anywhere a way to do that, the only solution for me wold be to write a temp file and then use that to create the ISchematronResource and then validate the xml

Instead of this
SchematronResource aResSCH = SchematronResourceSCH.fromFile( file );
i would need something like this
ISchematronResource aResSCH = SchematronResourceSCH.fromInputStream( inputStream );
If that is just not possible then I guess I'll write a temp file...

@cshjsc cshjsc changed the title InputStream instead of file [question] InputStream instead of file Nov 24, 2021
@phax phax self-assigned this Nov 24, 2021
@phax
Copy link
Owner

phax commented Nov 24, 2021

Thanks. Good point - I will add this to the next version.
In the meantime you can build this factory method yourself like this:

  /**
   * Create a new {@link SchematronResourceSCH} from Schematron rules provided
   * by an arbitrary {@link InputStream}.<br>
   * <b>Important:</b> in this case, no include resolution will be performed!!
   *
   * @param sResourceID
   *        Resource ID to be used as the cache key. Should neither be
   *        <code>null</code> nor empty.
   * @param aSchematronIS
   *        The {@link InputStream} to read the Schematron rules from. May not
   *        be <code>null</code>.
   * @return Never <code>null</code>.
   * @since 6.2.6
   */
  @Nonnull
  public static SchematronResourceSCH fromInputStream (@Nonnull @Nonempty final String sResourceID,
                                                       @Nonnull final InputStream aSchematronIS)
  {
    return new SchematronResourceSCH (new ReadableResourceInputStream (sResourceID, aSchematronIS));
  }

phax added a commit that referenced this issue Nov 24, 2021
@phax
Copy link
Owner

phax commented Nov 24, 2021

Will be part of the 6.2.6 release. Thanks for pointing that out!

@phax phax closed this as completed Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants