This issue should now be fixed in the main branch.
On 2023-08-03 02:35 PM, Lara Blatchford wrote:
Thanks Steve, I'll investigate those options
Lara
-----Original Message-----
From: Steve Lawrence <slawre...@apache.org>
Sent: Thursday, August 3, 2023 1:20 PM
To: users@daffodil.apache.org
Subject: Re: blob api issues in 3.5.0
I've tracked this down to being caused by enabling full validation. If you
change it to limited or off, configuring blob attributes should work as
expected. Unfortunately, there isn't really a great alternative. You could
change the java.io.tmpdir property to change the directory, but you can't
change the prefix/suffix, and changing that could potentially affect other
things.
I've added some additional low level details on the cause here:
https://usg02.safelinks.protection.office365.us/?url=https%3A%2F%2Fissues.apache.org%2Fjira%2Fbrowse%2FDAFFODIL-2837&data=05%7C01%7Clara.blatchford%40nteligen.com%7Cdad4521505064950f07e08db9445ea53%7C379c214c5c944e86a6062d047675f02a%7C0%7C0%7C638266800238607241%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=xWypt7g9LqExL0O5JOt4ZLkLuH24eSmLuAauJ4h9gDc%3D&reserved=0
Fortunately, the fix should be pretty small and straightforward.
On 2023-08-03 11:51 AM, Lara Blatchford wrote:
Good morning -
I'm trying to set a custom directory for blob files corresponding to
xs:anyUri elements to be written to. Despite setting a custom
directory, prefix and suffix via
XMLTextInfosetOutputter.setBlobAttributes(), the files are still
written to /tmp and do not use the prefix and suffix I specified.
Additionally, when I call xMLTextInfosetOutputter.getBlobPaths() after
parsing, the list of files is empty despite files having been written.
Example code shown below. Am I doing something incorrectly? I could
not find an example. I'm using the Java API.
Thanks,
Lara
public void parse ( String schema, String inFile, String outFile,
String uriDirectory ) throws Exception
{
Compiler compiler = Daffodil.compiler( );
ProcessorFactory pf = compiler.compileFile( new File( schema ) );
if ( pf.isError( ) )
{
System.err.println( "Failed to load schema: " + schema + ", " +
asString( pf.getDiagnostics( ) ) );
}
else
{
DataProcessor processor = pf.onPath( "/" );
try
{
processor = processor.withValidationMode( ValidationMode.Full
);
}
catch ( InvalidUsageException ex )
{
throw new Exception( "Invalid validation mode: " +
ex.getMessage( ), ex );
}
try ( FileInputStream fis = new FileInputStream( new File (
inFile ) );
FileOutputStream fos = new FileOutputStream( new File(
outFile ) ) )
{
InputSourceDataInputStream dis = new
InputSourceDataInputStream( fis );
XMLTextInfosetOutputter xto = new XMLTextInfosetOutputter(
fos, false );
// write blobs from anyURI elements to uriDirectory with
extension dab (daffodil blob )
Path uriPath = Paths.get( uriDirectory );
if ( !Files.exists( uriPath ) )
{
throw new IOException( uriDirectory + " directory does not
exist" );
}
String prefix = "dfdltoxml";
String suffix = "dab";
xto.setBlobAttributes( uriPath, prefix, suffix );
ParseResult result = processor.parse( dis, xto );
if ( result.isError( ) )
{
throw new Exception( "Parse error" );
}
// get list of blbos written to uri directory
List<Path> blobPaths = JavaConverters.seqAsJavaList(
xto.getBlobPaths( ) );
System.out.println( "Blob files written:" );
for ( Path p : blobPaths )
{
System.out.println( p.toString( ) );
}
}
}
}