MIME Type of Wavefront's OBJ and MTL - mime

I was building a little 3D-application using ThreeJS and WebGL. I purposely chose not to convert models into ThreeJS compatible .json files, instead started building an importer. It works, but I also planned to have the application decide what type of model has been loaded using both file extension and MIME type, the later if the first is unknown.
I've read somewhere that the MIME Type is supposed to be application/wavefront-obj, which would be kind of weird since there is also the model tree, but okay anyways. Though browsing the IANA website for this file type yields no results.
Am I missing something?

According to wikipedia, it's text/plain for .obj.
I'm guessing it's text/plain for .mtl files as well, since there's text in them and since it "is a standard defined by Wavefront Technologies for ASCII files".

You need to update your web.config and add the reference to the obj file type
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".obj" />
<mimeMap fileExtension=".obj" mimeType="text/plain" />
</staticContent>
</system.webServer>
</configuration>

Use MIME type application/object for .obj files. It works in Chrome, Safari, and FireFox.

I was surprised to see nothing in the IANA database for wavefront obj files, considering that they've been kicking around the internet for 20 years at least. I'd be happy to collaborate with others in establishing an official MIME type.
Until then, according to section 3.3 of RFC 6838, "Personal or Vanity Tree", you can use your own media type for this, something like text/prs.wavefront-obj, in addition to text/plain. That way you can use the HTTP Accept header to negotiate the appropriate MIME type in your response.

According to IANA, the association who defines and maintains media-types (this is not Wikipedia), the mime-type of "obj" is model/obj, and model/mtl for "mtl". See other media types for models: https://www.iana.org/assignments/media-types/media-types.xhtml#model

Related

Extending Visual Studio 2017 XML editor

I'm trying to improve our workflow with some XML-configuration files we use in a Visual Studio Solution. I figured I'll start with explaining what I'm trying to accomplish and then explain some of my ideas that I've tried for several hours without success.
The Problem
I'm working with a system where the data model is configured in a database, the models are also stored on disk using xml-files, these are then synced during startup of the app. Here's part of the stuff that are synced:
Data Types
All data types lives in one XML configuration file per data type and each has some properties like Name and Key. All data types are configured in the same folder, example: /config/dataTypes
Example
textString.config
<?xml version="1.0" encoding="UTF-8" ?>
<DataType Key="a45c9a94-09d7-4df9-85e6-d6930abc6c12" Name="Textstring">
textArea.config
<?xml version="1.0" encoding="UTF-8" ?>
<DataType Key="b104788f-4e2f-4592-9387-8b3861bd8046" Name="Textarea">
Entity Types
Think of these as models with X number of properties, each property is configured and connected to a Data Type.
Example
customer.config
<?xml version="1.0" encoding="UTF-8" ?>
<Entity>
<Properties>
<Property Name="Firstname" TypeKey="a45c9a94-09d7-4df9-85e6-d6930abc6c12" />
<Property Name="Lastname" TypeKey="a45c9a94-09d7-4df9-85e6-d6930abc6c12" />
<Property Name="Description" TypeKey="b104788f-4e2f-4592-9387-8b3861bd8046" />
</Properties>
</Entity>
My end goal is to provide intellisense when editing a Entity Type so that I'll get all the Data Types as suggestions when entering the "TypeKey" property of the Property element. Preferably showing the Name of the data type in the dropdown list and when choosing it adding the guid as value for the TypeKey-property. I would also like to show the Data Types name when hovering the GUID with the mouse (or in some other way).
As you can imagen during the process with a project new data types can be added so the intellisense needs to be dynamic based on the files in the data types-folder.
I should also mention that these configuration files also can be edited from a UI in the application and I don't have control over how they are serialized, hence - there is no XML namespace in the files, they look like in the examples above.
We also have multiple different VS-solutions with different setups of Data Types and Entity Types. So we need individual intellisense in each project.
What I've tried
My first idea was to create a VS-extension that creates a dynamic XML Schema XSD-file based on the files in the data types folder. The VS would then pick up and use the XSD for XML-files in the Project, turns out that this only works with a namespace configured (remember, I can't add namespaces since I don't control the external app).
To get around this it worked to manually add the schema-file to the XML file while editing the file. (Like this: https://learn.microsoft.com/en-us/visualstudio/xml-tools/how-to-select-the-xml-schemas-to-use?view=vs-2019). The problem with this is that it needs to be done for each xml-file and the setting is not stored.
I then started to play with the VS extension possibilities to try to automatically configure this Schema to a XML-file that is opened. Turns out I had a really hard time to get the "configuration object" that is pushed to the Properties Browser when the XML file is opened. I managed to get a event-handler setup that was triggered when the XML files as getting "focus" but I was stucked trying getting the properties from the Properties Browser.
I also tried another approach with a custom "code completion"-extension but it made the UI feel very "cluttered" while editing.
After spending about 10 hours playing around with this I feel I don't really have a good path to a solution as my experience with VS-extensions is not that extensive.
I would love to get some feedback and ideas on how to approach this problem, since the XSD is different from each project if I go down the "dynamic" path we can't use the global VS settings since each project has different data types hence needs different allowed values for the TypeKey property.
One approach that I'm thinking about is to use a generic XSD (allowing all values for the TypeKey) in the Global Schema Cache for Visual Studio and create a "code completion"-feature for just the TypeKeys.
Any thoughts and pointers in the right direction would be very much appreciated.

FHIR .NET API How to support Unknown Member in Resource?

I am working with a FHIR server that has Customized member in the resource.
Say if we receive a Patient with the following
xml = "<Patient xmlns='http://hl7.org/fhir'><hasSuperPower></hasSuperPower></Patient>";
How do I add the extra tag support in the FHIR .NET API so I can work with this Customized Resource? (so that the Deserilizer can process it and put it in a Patient Object.)
I have read from Mirjam Baltus 's post that the Model classes can be enhanced because they are all declared as "Partial class". Does
this mean I have to work with the FHIR API source code and add my own Partial class there and then re-compile it?
Would there be a way that I can just use the DLL from Nuget without have to touch the source code?
Why would you use a customized element rather than the standard extension element? Adding custom elements in this way is not compliant with the standard, won't work with any of the public test servers, won't interoperate with other FHIR systems and won't work with the reference implementations. Have you looked at the extensibility portion of the spec?
I've answered this in the Google forum as well, and agree with Lloyd.
If you receive a Patient with a <hasSuperPower> tag, that is not a FHIR compliant Patient.
FHIR has an excellent way to communicate data that doesn't fit in any of the standard fields, called extensions. If you use these, there is no need to write extra code to handle non-FHIR resources, and you can just use the existing libraries without having to change anything to them.
The superpower ability could look like this, and be FHIR compliant:
<Patient xmlns="http://hl7.org/fhir">
<extension url="http://mirjams.example.org/fhir/StructureDefinition/super-patient">
<valueBoolean value="true"/>
</extension>
</Patient>
I'd also like to point out this blog by Brian Postlethwaite about custom resource properties: https://brianpos.com/2018/05/03/code-generation-fhir-custom-resources/

IBM SBT: Updating a subcommunity breaks subcommunity relation?

I have implemented creation of subcommunities using IBM SBT 1.0.2.20140527-1807 against IC 4.5 (thanks for heavy API changes from 1.0.1 :-/ ) and want to update a freshly created subcommunity with a nice "content" containing some HTML with links to some content inside this community. Thus I must first create the subcommunity and afterwards update the "content" attribute, because I need some data not yet present before successful creation.
The way I do this is basically as follows:
(1) Create subcommunity [proven successful, and it IS a subcommunity now]
(2) Fetch the new subcommunity using CommunityService.getCommunity(communityUuid) [proven successful]
(3) execute community.setContent(string) [no errors]
(4) execute CommunityService.updateCommunity(community) [no errors]
The REST request created and sent for CREATE is:
POST /communities/service/atom/community/subcommunities?communityUuid=8ea4ff45-ef58-4c9b-b131-def2d3e233f7
The XML data sent is:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">mytitle</title>
<content type="html">mycontent</content>
<category term="community" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
<category term="mytag"></category>
<snx:communityType xmlns:snx="http://www.ibm.com/xmlns/prod/sn">private</snx:communityType>
</entry>
The REST request created and sent for UPDATE is:
PUT /communities/service/atom/community/instance?communityUuid=ae63bedf-98f2-45d4-ad6a-4dfd1f3a58d7
The XML data sent is:
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:snx="http://www.ibm.com/xmlns/prod/sn">
<title type="text">mytitle</title>
<content type="html">mycontent</content>
<category term="community" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
<category term="mytag"></category>
<snx:communityType xmlns:snx="http://www.ibm.com/xmlns/prod/sn">private</snx:communityType>
<snx:communityUuid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">ae63bedf-98f2-45d4-ad6a-4dfd1f3a58d7</snx:communityUuid>
<id>http://communities.ibm.com:2006/service/atom/community/instance?communityUuid=ae63bedf-98f2-45d4-ad6a-4dfd1f3a58d7</id>
</entry>
Afterwards the content is indeed updated -- but the community is not a subcommunity any more, but a regular top level community.
Why is that?
What can I do about it?
For the impatient: I have found the root cause, and in some circumstances this offers the possibility for a workaround.
The root cause is that the Community representation in IBM SBT SDK (Java) currently (as of July 2014) does not offer a "parent community URL" element.
http://www-10.lotus.com/ldd/appdevwiki.nsf/xpDocViewer.xsp?lookupName=IBM+Connections+4.5+API+Documentation#action=openDocument&res_title=Community_entry_content_ic45&content=pdcontent says that a community XML representation has a <link rel="http://www.ibm.com/xmlns/prod/sn/parentcommunity" type="application/atom+xml" href="..." /> element (where href is the atom/instance URL, not the "community URL" with html/communityview) if it represents a subcommunity, which is ignored on PUT/POST -- but:
THIS IS NOT TRUE:
In fact this element is REQUIRED on PUT to keep a community's "sub community" nature on change. And worse: If it is broken, it cannot be "repaired": Because of other limitations for subcommunities, an existing community cannot be changed to become a subcommunity of another top level community. Subcommunities can only be CREATED (and kept, of course).
What I have done to work around that pitfall is to subclass Community and some other classes to extend the XML marshal/unmarshal mechanisms in SBT SDK to cope with parent community URLs. If you know what you're doing everything is fine, but if you want generic code which simply does not break subcommunities, you must also READ ALL COMMUNITIES as if they may be subcommunities. If you don't, you won't see this information and write back the community as top level community.
Thus it is better to wait if you can :-(
I expect IBM to extend the implementation of Community and related classes by a parent community URL field. What I am curious about is how they will deal with the fact that the complete Atom feed URL is required, including the server address and the parent community UUID. I took the q&d way and changed the community URL as returned by parentCommunity.getCommunityUrl(), but this eventually does not take into account the various AUTH variants.
IBM SBT SDK 1.1.0 of Jul 17, 2014, seems to be out. At least it is available in Maven central.
This is the better answer of course but will require several code adjustments if you have built code on top of internal structures due to some internal refactorings.

xml to wbxml conversion for activesync in iOS

I have been trying to built an app which will communicate with MS-ActiveSync Exchange. I am stuck at the provisioning part. I need to send a post HTTP request with WBXML content in body. But I could not find anything anywhere to convert xml to wbxml for active sync.
There are some C based libraries available like wbxml2, but can I use them for active sync. There are no code pages provided in the library as mentioned in MS-Activesync Exchange documentation. Please help!!!
Use libwbxml. The package has xml2wbxml and wbxml2xml. Code pages are included.
save this as prov.xml:
<?xml version="1.0"?>
<!DOCTYPE ActiveSync PUBLIC "-//MICROSOFT//DTD ActiveSync//EN" "http://www.microsoft.com/">
<Provision xmlns="Provision:">
<Policies>
<Policy>
<PolicyType>MS-WAP-Provisioning-XML</PolicyType>
</Policy></Policies></Provision>
then:
xml2wbxml -a prov.xml -o prov.wbxml
You can manipulate wbxml as text.
In https://code.google.com/p/tz-push/
In javascript:
prov.wbxml = string.fromCharCode(0x03,0x01,0x6A,0x00,0x00,0x0E,0x45,0x46,0x47,0x48,0x03,0x4D,0x53,0x2D,0x57,0x41,0x50,0x2D,0x50,0x72,0x6F,0x76,0x69,0x73,0x69,0x6F,0x6E,0x69,0x6E,0x67,0x2D,0x58,0x4D,0x4C,0x00,0x01,0x01,0x01,0x01)
wbxml2xml and xml2wbxml are command line programs included with libwbxml. I know nothing about IOS development.
Have a look at https://tz-push.googlecode.com/files/towbxml.js it is xml to wbxml converter written in js. (Can be run in Thunderbird/Workspace or Firefox/Sratchpad.) I know this is not what you want but the code may point you in the correct direction. It uses Sax. So if you have a sax parser available should be easy to port.

iis7 default mime type behavior

So in IIS 7 if there is no specific MIME definition for a certain extension, it will refuse to serve it (404) even if you can see it in a directory listing. I'm sure this is a fairly known issue, but is there a way to wildcard or set a default action for unknown file types? I want everything to be offered for download by default like with every other webserver I've used.
Add a new MIME type for files of extension * with a type of application/octet-stream. This will provide a default MIME type for all files that don't have one and bypass the blocking.
The risk, however, is you end up sharing your confidential database, configuration files and whatnot, so make sure you know what you are doing before you open your server to all downloads.
+1 #H2Professor
But here's the code (in this case web.config for IIS 7+):
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension="*" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
I believe you just need to edit your website in Internet Information Services Manager and double click the Request Filtering icon and edit it however you like there.
The mime type configuration does not allow/disallow downloading files; it just tells IIS what to throw in the header when you do download it.

Resources