TrimDuplicates element of Microsoft.Search.Query Webservice causes a FormatException - web-services

I'm trying to search through a site collection and find all sites that contain a particular file. TrimDuplicates is supposed to be the right way to do that. I'm calling QueryEx of the WebService object with the following XML as the string argument.
<QueryPacket xmlns='urn:Microsoft.Search.Query'>
<Query>
<TrimDuplicates includeid="false">False</TrimDuplicates>
<SupportedFormats>
<Format revision='1'>urn:Microsoft.Search.Response.Document:Document</Format>
</SupportedFormats>
<Context>
<QueryText language='en-us' type='STRING'>
"filenameForQuery"
</QueryText>
</Context>
</Query>
</QueryPacket>
The response from search.asmx is a 500 error with System.FormatException as the only piece of useful information.
It's only the TrimDuplicates element that is triggering the formatexception. Fiddling the case of the two Falses hasn't had any effect so far.

The answer is actually blindingly obvious - remove the includeid attribute and make the content of TrimDuplicates lower case.

Just wanted to point out that includeid should actually be an integer value.
More here
But as you said, it's not necessary.

Related

How to skip a self closing tag in a ST function on an SAP system?

So I have this problem handling an XML file in my SAP ABAP-based software, with a Simple Transformation.
The file I receive have normally no empty tags like <test></test>, but can happen sometimes that I receive some self closing tag like <test/>.
This is an example of what I thought to use now. The first condition handles if the ref('test') is blank by skipping it. The second one takes the values if we have one.
<tt:cond check="initial(ref('test'))">
<tt:skip count="*" name="test"/>
</tt:cond>
<tt:cond check="not-initial(ref('test'))">
<test tt:value-ref="test"/>
</tt:cond>
The idea is: if we have this tag <test/> we need to skip it, otherwise we need to assign the data. Now, this working in the first case, cause he takes no date, but not in the second cause it not takes the data again.
Someone can help?
Thanks in advantages.
The XDM tree representations of <test></test> and <test/> are 100% identical, so there is no way an XSLT stylesheet can distinguish them or treat them differently. The idea of attaching different meanings to the two constructs is completely misguided: you can never be sure which representation an XML library will choose to use.
It is of course possible to distinguish an element that contains a value (such as <test>value</test>) from one that is empty - but both the above examples represent empty elements and must be treated as equivalent.

RegEx to remove specific XML elements

I'm using Kate to process text to create an XML file but I've hit a roadblock. The text now contains additional data that I need to remove based on its content.
To be specific, I have an XML element called <officers> that contains 0 or more <officer> elements, which contain further elements such as <title>, <name>, etc.. While I probably could exclude these at run time using XSL, the file also drives another process that I don't want to touch - it's a general purpose data importer for Scribus so I don't want to touch the coding.
What I want to do is remove an <officer> element if the <title> content isn't what I want. For example, I don't want the First VP, so I'd like to remove:
<officer>
<title>First VP</title>
<incumbent>Joe Somebody</incumbent>
<address>....</address>
<address>....</address>
......
</officer>
I don't know how many lines will be in any <officer> element nor what positions they will in within the <officers> element.
The easy part it getting to the start of the content I want removed. The hard part is getting to the </officer> end tag. All the solutions I've found so far just result in Kate deciding that the RegEx is invalid.
Any suggestions are appreciated.
Regex is the wrong tool for this job; never process XML without a proper parser, except possibly for a one-off job on a single document where you will throw the code away after running it and checking the results by hand. You might find a regex that works on one sample document, but you'll never get it to work properly on a well-designed set of 100 test documents.
And it's easily done using XSLT. It's a stylesheet with two template rules: a default "identity template" rule to copy elements unchanged, and a second rule to delete the elements you don't want. In fact in XSLT 3.0 it gets even simpler:
<xsl:mode on-no-match="shallow-copy"/>
<xsl:template match="officer[title='First VP']"/>

Regex or Xpath for extracting nodes?

I have an XML file with the following structure;
<JobList>
<Job><subnodes/></Job>
<Job><subnodes/></Job>
</JobList>
This xml can be broken sometimes leaving a missing ending of <JobList> and missing end of </Job>.
I would like to be able to extract the <Job> nodes with full content on those that are closed with </Job>. What is the best way to do this?
To make a long story short I am using .NET and built in serializers for deserializing xml content. But since new properties are added you cannot just go back and forth between different versions as it is to strict. Mostly it works, but I would like to have a backup recovery method for this - hence the question.
The current situation is that the deserializer "crashes" the whole deserializing when a new property has been added instead of ignoring it. I am looking to manually parse it on error.
As mentioned on the comments, the ideal would be to make the xml valid, if for whatever reason that is not possible, the workaround is parsing the file as text with a regex.
A general regex for this case could be something like:
<Job>((?!<Job>).)*</Job>$
this will bring anything between a complete pair
Please notice that this will also return nodes with 'broken' inner nodes, but according to your question you are only concerned about missing and tags.

What does <var name="ROMAN"> mean in xsl

I am really facing a strange problem. ROMAN characters are not displaying at all in mozilla and google chrome except on IE8(not in IE10 as well).
The code was written using xsl transformations. and i am unable to find what does
<var name="ROMAN"> is? This is the exact text when i see the html source.
Even the same code is written in xsl.
Any help would be greatly appreciable.
<var> is an HTML element that means "This is a variable". It will typically cause the contained text to be rendered in italic. It doesn't mean anything special to XSLT, it's just like any other HTML element name. name="ROMAN" is just like the name attribute of any other HTML element, it can be used in Javascript to address the relevant element node in the page. It doesn't change the rendition of the element, unless perhaps there is some stylesheet somewhere that recognizes name="ROMAN" and associates it with a display style.
I think you've got an HTML question, not an XSLT question. There's something wrong with your HTML, and we don't know what, because you haven't given enough information.

MarkLogic: Trying to understand error "Node has complex type with non-mixed complex content"

I'm getting this error during pipeline processing of an xml document, the processing does an xslt transform. It appears to be telling me that the document is in some way invalid, however the document passes validation against the xsd in Oxygen.
First, the error is not telling me the line number in the offending data file, just the line number in the pipeline xqy file, from what I can tell.
Second: The error is grammatically non-sensical to me: It seems to say that a node in the document is defined as a complex type, but that content in the document is non-mixed...why would that matter? Most content is non-mixed, right? So non-mixed content is as I see it sort of the norm in most xml that I see. Thanks.
The error can also occur when some function is expecting a more simple value as argument, but receiving complex element types.
Actually, searching in the archives at http://marklogic.markmail.org/ the error seems to be coming from fn:data() if it is passed 'too' complex values to put it briefly. I think the message is meant to say that the node that is being passed in doesn't have a typed value. See also here: http://www.w3.org/TR/xpath-functions/#func-data
If you provide the full error message, we might be able to help you out..
The document is likely valid, but it doesn't conform to expectations in your XSLT code. Without seeing code and document, muy hunch is that the XSLT is expecting the matching document node to be an element (or similar) but it is an attribute or text node.