XDT Config Transforms - ReplaceAll? - visual-studio-2010

I've got a custom section in my web.config file similar to this structure:
<Messages>
<Message id="1'>
<Property Name="foo" value="bar" />
</Message>
<Message id="2'>
<Property Name="foo" value="bar2" />
</Message>
</Messages>
I want to apply a custom transformation on this such that I can change the value of ALL instances of the Property element with Name="foo" - but I cant seem to get it to work.
I've tried:
<Messages>
<Message>
<Property Name="foo" value="updated" xdt:Locator=Match(Name) xdt:Transform="Replace" />
</Message>
</Mesasges>
I can remove all the elements by replacing the Transform=Replace with a Transform=RemoveAll - any ideas how I can achieve something similar to replace all the values?

It seems like Transform:Replace only replaces the first matched element from the documentation on msdn: ...If more than one element is selected, only the first selected element is replaced. I solved this issue by using a combination of Match-Conditions and SetAttributes, something like:
<Messages>
<Message>
<Property value="updated" xdt:Locator=Condition(#Name='foo') xdt:Transform="SetAttributes(value)" />
</Message>
</Messages>

Related

Resharper - Code Cleanup - Sorting methods.. Can I make exception that will be last?

Is there an option for exception for cleaning methods?
I have methods Serialize and Deserialize. I would like them to be at the end of the file after Resharper sorts other methods.
Is this doable only with Resharper?
You may try updating ReSharper | Options | Code Editing | C# | File Layout to get the sorting you need:
You have already had an entry to match Methods:
<Entry DisplayName="Methods">
<Entry.Match>
<Kind Is="Method" />
</Entry.Match>
<Entry.SortBy>
<Name />
</Entry.SortBy>
</Entry>
Now you need to exclude "Serialize" and "Deserialize" name from matching in the current block:
<Entry DisplayName="Methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Not>
<Or>
<Name Is="Serialize" />
<Name Is="Deserialize" />
</Or>
</Not>
</And>
</Entry.Match>
<Entry.SortBy>
<Name />
</Entry.SortBy>
Then add a new Entry below "Methods" entry to match "Serialize" and "Deserialize" methods:
<Entry DisplayName="Deserialize/Serialize Methods">
<Entry.Match>
<And>
<Kind Is="Method" />
<Or>
<Name Is="Serialize" />
<Name Is="Deserialize" />
</Or>
</And>
</Entry.Match>
</Entry>

Can a FHIR extension be defined within the StructureDefinition of a profiled resource?

Does a FHIR extension always have to be defined in its own StructureDefinition before it can be used in a resource profile?
Or can its definition exist solely within the StructureDefinition of a profiled resource?
E.g.
<StructureDefinition xmlns="http://hl7.org/fhir">
<base value="http://hl7.org/fhir/StructureDefinition/Order" />
<name value="Order" />
...
<differential>
<element>
<path value="Order.extension" />
<name value="type" />
<label value="Type" />
<short value="BookAppointment | TelephonePatient | PatientNote | Note | Other" />
<definition value="Order type" />
<min value="1" />
<max value="1" />
<type>
<code value="code" />
</type>
<binding>
<strength value="required" />
<valueSetReference>
<reference value="http://test.org/fhir/ValueSet/task-type" />
</valueSetReference>
</binding>
</element>
...
Is the above valid?
No, that's not valid - because Order.extension can't have a type of "code". You could, in theory, slice extension and constrain the value[x] type to be valueCode with the specified properties. You'd also have to constrain the URL to a specified fixed value. The tricky part is that the URL you indicate as the fixed value is supposed to resolve to a StructureDefinition that defines the extension. So you really won't have saved yourself any work. Sending an instance where any immediate receiver can't discover the extension definition would make you automatically non-conformant.

How-to include an optional Bag in my hbm.xml file?

How do I make the Bag optional for class Test in the following pseudo hbm.xml?
<class name="Test" table="test">
<bag name="bag" table="example" cascade="all" fetch="join">
<key property-ref="key">
<column name="a_id" />
<column name="b_id" />
</key>
<element column="example_id"
type="my.myclass"/>
</bag></class>
my.mclass is a custom type (my.myclass implements org.hibernate.usertype.UserType)
In the moment if there is no fitting "test example" row in the example table I get an exception?
(I was hoping to find a kind of not-found attribute? But there is no)
What's the relationship between Test and myclass? 1 to many or many to many?
If it's 1 to many in your case, I will suggest you create separate mapping for myclass and use following mapping for Test class
<bag name="bag" table="example" inverse="true" cascade="all" fetch="join">
<key property-ref="key">
<column name="a_id" />
<column name="b_id" />
</key>
<one-to-many class="my.myclass"/>
</bag>

How We Can Break a String in Wso2esb using Xpath

I wish to break a string in wso2esb using xpath
my input like this
<property name="Message" value="assetname:ups,assetcode:452chi,assetid:548935,assetvalue:215" scope="default"/>
i need break in same property using xpath
i need like this
assetname:ups
assetcode=452chi
assetid=54895
assetvalue=215
for this i tried with tokenize function but wso2esb showing errors
my configure file
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Xpathcheck" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="max" value="1" scope="default" type="STRING"/>
<property name="min" value="1" scope="default" type="STRING"/>
<property name="MessageText" expression="fn:concat('Assetid:',get-property('min'),',','Assetname:',get-property('max'))" scope="default" type="STRING"/>
<property name="Tokenize" expression="fn:tokenize(get-property('Messagetext'),',')" scope="default" type="STRING"/>
<log>
<property name="MessageText" expression="get-property('MessageText')"/>
<property name="Tokenize" expression="get-property('Tokenize')"/>
</log>
</inSequence>
<outSequence/>
</target>
<description></description>
</proxy>
But its throwing errors like this u have any idea for this i need store this in Db table as a one field which look like separate lines
error is
ERROR - SynapseXPath Evaluation of the XPath expression fn:tokenize(get-property('Messagetext'),',') resulted in an error
org.jaxen.UnresolvableException: No Such Function tokenize
tokenize is a function comes with XPath 2.0. To enable XPath 2.0 functions uncomment the following entry in the synapse.properties file which is located at $ESB_HOME/repository/conf directory
synapse.xpath.dom.failover.enabled=true
then you have to specify the mediator as follows,
<property name="Message" value="a,b,c,d,e" scope="default"/>
<property xmlns:fn="http://www.w3.org/2005/xpath-functions" name="Tokenize" expression="fn:tokenize(syn:get-property('Message'),',')" scope="default" type="STRING"/>
I dont think this can be done through XPath, XPath is to navigate elements in an XML. You can do this by using a script mediator and write a JS to break the property values.
use the following to access the ESB params from the script mediator
<script language="js"> var test_param = mc.getProperty('Message')
Use the following to retrieve the params within the script mediator back to the ESB
mc.setProperty("param1",var1)
mc.setProperty("param2",var2)
Use the javascript to carry out the required string manupulations

Referencing specific element(s) in a RelaxNG schema with externalRef

So I have one RelaxNG schema that references another:
<define name="review">
<element name="review">
<externalRef href="other.rng"/>
</element>
</define>
other.rng:
<start>
<choice>
<ref name="good"/>
<ref name="bad"/>
</choice>
</start>
<define name="good">
<element name="good"/>
</define>
<define name="bad">
<element name="bad"/>
</define>
Is there any way I can import only <good>, but not allow <bad>? The goal being:
<review><good/></review>: valid
<review><bad/></review>: invalid
The grammar you import with externalRef can't be modified. To achieve the kind of validation you're after, I see this method :
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<include href="other.rng">
<start combine="choice">
<ref name="review"/>
</start>
</include>
<define name="review">
<element name="review">
<ref name="good"/>
</element>
</define>
</grammar>
You include the other schema.
You override the start element in the include (good and bad elements won't be possible root).
The specification says :
If the include element has a start component, then all start
components are removed from the grammar element.
You make a reference to the good element in your review definition.

Resources