XMLReadFile mixed the header proprties - c

I created an XGMML document (doc a), and set the Header properties as I wished (and needed to), and I checked on notepad++ that I got the desired format.
when trying to open it with XMLReadFile, and saving the document under other name (doc b), the Header properties mixed up.
I think it happens on opening because when I opened doc a (the good file) on chrome the Header was mixed exactly in the same way it was on doc b. so I think chrome and XMLReadFile open the XGMML document in the same way (mixing the Header up), and on saving nothing bad happens.
more importantly, I don't know of other function that opens the XGMML document and doesn't change the Header - it is really important that the Header or any other field won't be changed (I tried to use XMLParseFile but it seems to cause the same problem).
do you know why it happens?
and do you know of a function that opens XGMML document and doesn't mix the Header (or any other field) up?

Assuming you refer to attributes as properties: An XML element's attributes do not have a significant order by definition. Please see the standard here.

Related

How to get the icon path and index associated with a file type (again, with clarity)?

It's a long shot, but does anyone know of a working method to get the associated icon location (= path to an exe/dll/ico file) and ID for a given filename with WinAPI. The point is to create a shortcut to another file (which may or may not be of the same file type) and set THIS exact icon, overriding its default one, presumably with IShellLink::SetIconLocation.
Things that don't work:
-ExtractAssociatedIcon
-SHGetFileInfo
-IExtractIcon
Return random crap with GIL_NOTFILENAME flag set for any of the default file types I've tried (like txt).
There seem to be several topics on SO about this sorta thing, with answers/non-answers suggesting one of the above. This one [1] appears most close to being informative. Their preferred method doesn't work either, but their other notes gave me the hint to try using the registry.
So for the time being, I wrote my own function that uses the registry [2], but it's also not perfect: in some cases, the registry stores 'positive icon IDs' that cannot, it seems, be used with SetIconLocation.
Honestly didn't expect this to be such a year 2023 problem
You don't need to call IShellLink::SetIconLocation if you don't want to override the targets default icon. Just point the shortcut to a .txt file and the shortcut automatically gets the correct icon.
Positive icon IDs most certainly can be used with SetIconLocation, that is the common case. Are you calling PathParseIconLocation?
GIL_NOTFILENAME is just something you have to accept, it usually means the icon comes from the system image list. The shell is mainly interested in going from a file/type to a HICON, not the other way around. The icon for a file may even be dynamic if it is implemented by a shell extension.
You can add AssocQueryString to the list of functions to try that will never work 100% of the time...

AngularJS - highlight text of an existing pdf file in frontend/Browser

I have found the library
PDF creation
With this library it is possible to create different styles of pdf documents.
My question would be if there is a possibility to mark text (and maybe add a link to this marked text) of an existing pdf file with AngularJS?
Or is there any workaround to do this?
The question is a bit too broad as is - not sure what you mean by "mark" - do you mean highlighted in some way or actually selected?
Anyhow, firstly to get to the correct page -- you can use fragment identifiers in hyperlinks to link to a specific page in a PDF via the page parameter. e.g.
page 1
page 2
If you want to highlight a specific section of a page, via a hyperlink, you can use the highlight parameter, note you must also set the page to use the highlight parameter. e.g.
page 1 - highlight
The rectangle values are integers in a coordinate system where 0,0 represents the top left, and the values are given in the order lt, rt, top, btm.
One can also open a PDF file to a "Named Destination", that is a named section in the document via the nameddest parameter. e.g.
my section
This is great as it doesn't matter if pages are inserted, removed etc as the section will always be correctly linked.
You can read about Named Destinations here and also the various Parameters for Opening PDF Files

Do not allow ".xml"/".html"/"index" in URI?

I'm going through Lift's basics in Section 3.2 SiteMap of Simply Lift and one thing struck me.
Using the default SiteMap code, you can ask for, say, info view in three ways:
GET /info,
GET /info.html,
GET /info.xml (why?).
What is more, you can request index view in four different ways:
GET /,
GET /index,
GET /index.html,
GET /index.xml.
How can I limit this behaviour to GET / for directories and GET /info for files?
P.S. All of these return 200 OK:
foursquare.com/,
foursquare.com/index,
foursquare.com/index.html,
foursquare.com/index.xml.
Shouldn't one resource have one URL only?
There are actually more than four ways that it can be parsed. The full list of known suffixes (any of which can be used to access the page) can be found here.
I think the reason for that is that lift can be used to serve any resource, so most are explicitly added by default.
I think you could disable Lift's processing of all extensions by adding this to Boot.scala:
LiftRules.explicitlyParsedSuffixes = Nil
However, I wouldn't recommend that as there may be some side-effects.
Using Req with RestHelper you can specify the suffix explicitly, but I don't know if there is such a construct to do so with Sitemap.
Actually, the code to determine whether Lift should handle the request or not is here. You can see the default extensions in the liftHandled method directly above, but they can all be overridden with LiftRules.liftRequest. Something like:
LiftRules.liftRequest append {
case r => Full(r.path.suffix.trim == "")
}
Should do the trick.
As far as why it works that way, Jason is right that Lift is designed to handle multiple types of dynamic resource.

CakePHP RequestHandler: setContent/renderAs/respondAs .. what?

Can someone please explain these functions:
RequestHandlerComponent::renderAs()
RequestHandlerComponent::respondAs()
RequestHandlerComponent::setContent()
It feels slightly redundant to have all three of them (as public methods anyway). If I want to respond to a request with a PDF file, does that mean I'd have to call all three functions? How should I use these in my controller?
They're all different. From the API Docs:
renderAs
Sets the layout and template paths for the content type defined by $type.
I.e. more or less a shortcut for $this->layout = '...' and $this->render(...).
respondAs
Sets the response header based on type map index name. If DEBUG is greater than 2, the header is not set.
Outputs header(...).
setContent
Adds/sets the Content-type(s) for the given name. This method allows content-types to be mapped to friendly aliases (or extensions), which allows RequestHandler to automatically respond to requests of that type in the startup method.
Doesn't actually do anything to the output, just allows you to add new types that are not defined by default.
For outputting a PDF (assuming you have it as a file already) you should actually use a Media View.

How Do I Use Multiple po Files in CakePHP?

I'm just beginning the process of exploring i18n in CakePHP and I can't seem to find the right combination of files and functions that will allow me to use multiple po files. If I want to use a single po file (default.po) for every bit of translatable text, that works fine, but I see that becoming an unmaintainable hairball very, very quickly. I've read the docs and the few articles I can find, but none really dive into i18n beyond the trivial use of one .po file.
Here's where I am right now:
I've "baked" my po templates (.pot files) and copied those into app/locale/eng/LC_MESSAGES (I'm not going to be using the default text as the key so that I can easily spot missing keys). For now, I have -views-layouts-default.po and -views-pages-index.po.
In those .po files, I've entered the text I want to use for each key.
In my homepage (views/pages/index.ctp) and default layout (views/layouts/default.ctp) I've wrapped the text key I want to translate with the __() function.
When I load the homepage, though, all I see are they keys. No text has been translated. If I throw up a default.po file, though, any keys I drop in there are populated just fine. I'm clearly missing some piece of the puzzle, but I can't find it. Any help would be much appreciated.
Thanks.
I found the piece I was missing thanks to the CakePHP Google Group. I had been playing with the __d() convenience function, but didn't have a clear picture of how to tie it together to my .po files. The answer is easy once you know it:
The domain translation:
__d ( 'login', 'PLEASE_LOGIN' );
Will look for the "PLEASE_LOGIN" key in the file named login.po. I didn't know (and hadn't read anywhere) that domain == po file name (without extension). Learning that made all the difference.

Resources