So I'm parsing flat files using 3 separate schemas - a header, trailer and body. I know that you can go into flat file disassembler properties and flip "Preserve header" to true and the header is injected into the context collection... but how can I do something similar for the footer?
This is sometimes difficult to do since BizTalk reads forward only it cannot just locate the footer, so you'll need to either use a tag identifier or build a custom disassembly component based on content of the footer record.
Related
I need to modify html coming from external file (server side) before I render it and inject a quote 'component' like this:
This component needs to be injected after 2nd paragraph and I'm planning to use htmlagillity pack. Any examples? Is HtmlNode.InsertAfter() method good choice once I found third paragraph which should be trivial.
Another question is would it be possible to inject sitecore placeholder or even usercontrol that is going to render my quote instead of pure html? I feel it should be but not sure what would be good approach.
Thanks
I can suggest two possible approaches here:
1) Use snippets with some customisation. Snippets allow users to insert pre-defined chunks of HTML into a RTE field. You could have a pre-defined piece of HTML which might have some identifier to indicate it should use custom processing (I would suggest some data-xxx style attribute which would not conflict with any CSS or JavaScript). Then you could create a new renderField pipeline processor which would detect the data-xxx attribute within the content of a rich text field - you would use HtmlAgilityPack for this and then replace that snippet with the contents of your server-side file.
-or-
2) Split your text content into two separate chunks and have two instances of a "HtmlText" rendering within the placeholder, with a rendering for your quote text between them in the same placeholder.
I would advise that having a rule to insert text after the second paragraph would be quite 'brittle' as this would be very reliant on content editors setting the rich text field contents in quite a precise way e.g. to always ensure two or more paragraphs and to always break text with paragraphs - they might decide to use a load of line breaks instead to split their text. That said if you did do this, you would create a new renderField pipeline processor.
We have a Tridion use case related to curated content where we are creating multimedia components for images associated with our content which are pointing to External resource types instead of uploaded resource types.
One of the issues we have run into with this use case is that despite explicitly setting the Multimedia Type for the resource, if the URL of the image has either a query string in it: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default or uses a ‘friendly url’: http://www.somewhere.com/images/myimage/ when we save the component, Tridion barfs with error messages similar to : ‘Invalid value for property 'Filename'. Unexpected file extension: jpg?w=160&h=120&mode=crop&404=default. Expecting: jpg,jpeg,jpe.’
So far, the only way we’ve been able to figure out to potentially get around this issue is to do something hacky like appending an extra query string parameter to the very end of the urls which end with the expected file extension: http://cdn.hw.net/UploadService/1c8b7f28-bb12-4e02-b888-388fdff5836e.jpg?w=160&h=120&mode=crop&404=default&ext=.jpg Obviously, this is not the best solution and in fact may not work for some images if the site they are being served from strictly validates the requested URL.
Does anyone have any ideas on how we can work around this issue?
Unfortunately I can't really think of an easy solution to this, since Tridion "detects" the Mime type by checking the file extension.
You could perhaps add it while saving and remove it when reading (via Event System)? Definitely a worthwhile enhancement request, to my knowledge this behavior has not been changed for the soon-coming Tridion 2013... See comment below, it has been changed for 2013.
+1 for Nuno's answer. Recognizing that the title of your question is specific to multimedia components, you may want to consider another approach which is to use normal Components, not Multimedia Components. You can create a normal component schema called something like "External Image" that has an External Url field to store your extentionless url.
Content authors will then include these images via regular component linking mechanisms in the Tridion GUI.
You will then need a custom link resolver TBB that will parse the Output item (via Regex) looking for any Tridion anchor tags <a tridion:href="tcm:x-y-z"> and for each one replace them with an <img src=...> tag where the src path would come from this linked component.
For an example of a similar approach, but with videos, and sample code for a custom link resolver TBB have a look at the code in the following post: http://www.tridiondeveloper.com/integration-sdl-tridion-jw-media-player.
Is it possible (or sensible) to build a custom MediaTypeMapping to select a MediaTypeFormatter based on content from the Request Body?
I'm thinking specifically of a case where I have a very non-descriptive text/plain in a multipart/form-data payload and I want to use heuristics to work out what's contained.
I'm currently doing this in a custom MediaTypeFormatter that looks at the first few lines, and if the content begins with { then it assumes JSON, if it's word,word,word the the commas indicate CSV.
I was thinking that a MediaTypeMapping would be cleaner but I don't know if it's sensible to try and match from the Body content.
Currently there is no way you can really Inspect content in Webapi. You can not read the stream more than once.
Currently I am working on an ASP.net webforms project where I would like to indicate to the user which elements on the current page contain localized resources.
In order to identify which HTML elements, contain which localized resources. I'd like to tag all rendered HTML elements that had a resource retrieved from the ResourceProvider while rendering the page. Thereby creating a mapping between HTML element and the used resource(s).
The tagging will be done by adding a data-localized attribute to the html element. The attribute will contain the resource identifier(s) used (i.e. resx file names and the resource keys), and then when the in the browser displays the page a javascript will use this information to do whatever.
So far I have replaced the default resource-provider with my own provider that retrieves resources from a database instead of the regular .resx files (as described in this article). This gives me information about all the resources used and by logging these in the HttpContext, i know all the resources used for the current page.
Now for the mapping, because the localized resource doesn't always have to occur within an HTML element (e.g. it could be just a string yielded by a Literal control). I have introduced a new CompositeControl that wraps a section containing localized resources with a <div data-localized=""> </div>.
My question: How can i map the wrapper with the resources used by its children?
Since you are going to post-process the data with JavaScript, you may think of adding what you need in form of prefix and delimiter to actual translated text, for example "Sample text" will become "##strings.resx##login.form.sample.text##Sample text".
Your client side script would then look for ## delimiters and remove them (or do whatever you want) from the page.
I know it is not what you asked for but I believe it is simpler and easier to implement.
So far all the XML / XSLT I've worked with takes an XML document and transforms it to a standalone HTML webpage using an XSLT file.
In my web application, I'm using a web service to retrieve the XML document, which I need to render and make human-readable, and then insert that formatted content into a content placeholder in my master page.
The easiest way would be to append the XSLT to the retrieved XML file and link that to the content placeholder, but something tells me I can't just do that.
I took a look at these Stack Overflow pages, but they just want to render the straight XML whereas I want a transformed XML. Also, I need to be able to put it into my master page template.
This article shows how:
http://www.codeproject.com/Articles/37868/Beginners-Introduction-To-XSL-Transform-Rendering-XML-Data-using-XSL-Get-HTML-output.aspx
even if the spelling is as bad as mine...
Added
And here's another link that shows how, perhaps a bit more simply
http://www.aspfree.com/c/a/XML/Applying-XSLT-to-XML-Using-ASP.NET/2/