I have a question about Microsoft's MSDN documentation for the Extenstions.GetSchemaInfo Method (XElement) for .Net framework 4.0.
I want to know if there's a way from within the
Private Sub DumpInvalidNodes(ByVal el As XElement)
If el.GetSchemaInfo.Validity <> XmlSchemaValidity.Valid Then
...
End If
End Sub
Code to get the ValidationEventArgs.Message for the invalid node. This example works fine when you have numbered XML nodes like in the example: GrandChild1, GrandChild2. You can tell which invalid node is producing the validation errors by site. But when you have XML without numbered nodes, e.g.
<Root>
<Child>
<GrandChild>AAA</GrandChild>
<GrandChild>ZZZ</GrandChild>
<GrandChild>ZZZ</GrandChild>
</Child>
</Root>
you get output that looks like this:
(1)Validating doc1 ...
(2)The 'GrandChild' element is invalid - The value 'ZZZ' is invalid according to its datatype 'GCType' - The Enumeration constraint failed.
(3)The 'GrandChild' element is invalid - The value 'ZZZ' is invalid according to its datatype 'GCType' - The Enumeration constraint failed.
(4)doc1 did not validate
(5)Invalid Element /Root
(6)Invalid Element /Root/Child
(7)Invalid Element /Root/Child/GrandChild
(8)Invalid Element /Root/Child/GrandChild
I wanted a way to tell that line (7) referred to the ErrorMessage in line (2).
I have an XML document that I'm running XSD validation against as this article shows and I wanted to parse the ValidationEventArgs.Message into a more user friendly message for complex data types. I'd like to do this in the DumpInvalidNodes() method because I have access to the invalid Node and can obtain other information from the node (like an ID) that the user can use to find and fix the validation problem.
The easiest way for you would be to modify the original code and instead of doing the node dumping after, do it in the validation handler; it'll give you the validation message and the node at the same time (simply cast the sender to an XObject and deal with it as you need).
For XML loaded from files or strings you could also use this MSDN article here. Additional hints to the user, such as line number and column position, could also be useful.
Related
Within the dimension properties for an attribute within SSAS, there is an option called TokenizationBehavior which is defaulted to TokenizationNone. The alternative is TokenizationText.
I tried it out and it gives an error message as per below. There is little content on the internet about anybody trying this out or what it is actually for. Any ideas? I'm not sure if this Tokenization is for parsing text or a security mechanism? And why it doesn't work or how it's supposed to work in SSAS?
The ddl500:TokenizationBehavior element (namespacehttp://schemas.microsoft.com/analysisservices/2013/engine/500) cannot appear under Envelope/Body/Execute/Command/Batch/Alter/ObjectDefinition/Database/Dimensions/Dimension/Attributes/Attribute
I looked at the XML code which adds the below line if you put TokenizationText in the dimension attribute properties:
<ddl500:TokenizationBehavior valuens="ddl500_500">TokenizationText</ddl500:TokenizationBehavior>
I am trying to add fields from VB.Net class file to SQL database, while doing "Add Migration" It is showing "startIndex cannot be larger than length of string."
enter image description here
I had the same error message when i tried to make a migration. The cause in my case was an empty value for MigrationId for a particular migration in the _MigrationHistory table.
This field must have a value in the same format as the string parameter of the attribute [Migration("YYYYMMDDHHMMSS_SeedData")], which is described in the other answer.
Most of all you have some class in your data project with attribute Migration (maybe for seeding data or something similar) which name is not in expected format like this:
[Migration("YYYYMMDDHHMMSS_SeedData")]
Adjust the migration name to be in YYYYMMDDHHMMSS_Description format to fix the error startIndex cannot be larger than length of string.
I have an xml document with a node that may optionally contain a string of escaped xml. I'd like to be able to transform that content using xsl in a BizTalk map. Any suggestion how?
I've tried:
msxsl:node-set(string). This creates a nameless single node with no content.
The document() function using a url prefix of 'data:text/xml' as suggested by helderdarocha here.
for-each selecting the text() of the node containing the string
using xpath() in an orchestration to extract the string then make a multipart message. It won't let me use an xmlDocument message as one of the messages in a multipart message transform.
Do I have to use a C# helper assembly to accomplish this?
I have tackled a similar issue in a project, where I have a series of 2 mappings (both native xslt).
The first map will map your input document to an intermediate format. This format has one "any" node (instead of the escaped XML node), where eventually, I put in the unescaped XML. I unescape using a C# extension object.
The C# code could just be a wrapper for System.Web.HttpUtility.HtmlDecode()
In the second mapping, you can map using plain XPath.
Example Input message:
<root>
<someNode>blabla</someNode>
<any><root2><myValue>escapedXml</myValue></root2></any>
</root>
Intermediate format:
<root>
<someNode>blabla</someNode>
<any>
<root2>
<myValue>escapedXml</myValue>
</root2>
</any>
</root>
In your second mapping, you could use XPaths like /root/any/root2/myValue/text() without any issue.
Important Note:
If you need to do XSD validation against this intermediate format, this is a good way to do this as well. You would just need to create the appropriate intermediate XSD according to your needs. In my case this was needed, so I had to validate this unescaped format using a receive pipeline execution in an orchestration.
I am trying to get the value of a node from third party source. Part of the Xmlstructure has a node whose name changes between, point and framedPoint. how do I get the latitude value?? here is part of the xml, their are many levels to the xml so have shown the relevant area.
here node is called point
<tpegpointLocation xsi:type="TPEGSimplePoint">
<point xsi:type="TPEGJunction">
<pointCoordinates>
<latitude>54.894825</latitude>
</pointCoordinates>
</point>
</tpegpointLocation>
here framedPoint
<tpegpointLocation xsi:type="TPEGSimplePoint">
<framedPoint xsi:type="TPEGJunction">
<pointCoordinates>
<latitude>54.894825</latitude>
</pointCoordinates>
</framedPoint>
</tpegpointLocation>
Thanks, for any help
You could use asterisk as a wildcard in your xpath
/tpegpointLocation/*/pointCoordinates/latitude
The following XPath would do the job:
//tpegpointLocation//pointCoordinates/latitude
Which means:
//tpegpointLocation search for all <tpegpointLocation> elements in the XML file
The second //pointCoordinates means search for all <pointCoordinates> elements below <tpegpointLocation> regardless which elements are between them (one or more or different names
/latitude means get the <latitude> element below <pointCoordinates>
Please note that using // scans whole XML file. If you are able to change //tpegpointLocation it would be better and faster.
I'm doing something like the following: Validate number of nested attributes.
I'm checking for existence of at least one nested attribute.
This was working fine when I was using a text input for the date but I've changed it to use a date_select instead and now the same validation code shows an error saying that not enough have been chosen.
When it fails validation and reloads the form it also doesn't "build" an instance of the nested attribute either so it just shows my "[+]" link
Anybody got any ideas?
Failing everything I'll just have to put the text field back (probably using type=date).
Col
I decided to just put the text field back.