UrlRewriter.net Expression Examples - urlrewriter.net

I need some web.config examples for each expression types below :
$number
The last substring matched by group number number.
$<name>
The last substring matched by group named name matched by (?< name > ).
${property}
The value of the property when the expression is evaluated.
${transform(value)}
The result of calling the transform on the specified value.
${map:value}
The result of mapping the specified value using the map. Replaced with empty string if no mapping exists.
${map:value|default}
The result of mapping the specified value using the map. Replaced with the default if no mapping exists.
Sample:
<rewriter>
<if url="/tags/(.+)" rewrite="/tagcloud.aspx?tag=$1" />
<!-- same thing as <rewrite url="/tags/(.+)" to="/tagcloud.aspx?tag=$1" /> -->
</rewriter>
Thank you very much !

Here's what I found/guessed. Not tested.
$number : http://urlrewriter.net/index.php/support/using
<rewrite url="^(.*)/(\?.+)?$" to="$1/default.aspx$2?" />
$1 matches (.*)
$2 matches (\?.+)
$< name > : this one I'm not so sure on the regex, couldn't find anything in documentation
<rewrite url="^(?<group1>(.*))/(\?.+)?$" to="$<group1>/default.aspx$2?" />
$<group1> matches
${property} : http://urlrewriter.net/index.php/support/reference/actions/set-property
<set property="branch" value="$3" />
<rewrite to="/showbranch.aspx?branch=${branch}" />
${transform(value)} : http://urlrewriter.net/index.php/support/reference/transforms
<set property="transform-name" value="lower" />
<set property="value-to-transform" value="THIS WAS UPPER CASE" />
<redirect to="/WebForm1.aspx?q=${encode(${${transform-name}(${value-to-transform})})}" />
results in "/WebForm1.aspx?q=this+was+upper+case"
${map:value} : http://urlrewriter.net/index.php/support/reference/transforms/static
<mapping name="areas">
<map from="sydney" to="1" />
<map from="melbourne" to="2" />
<map from="brisbane" to="3" />
</mapping>
<rewrite to="/area.aspx?area=${areas:$3}" />
results in "/area.aspx?area=brisbane"
${map:value|default}
<mapping name="areas">
<map from="sydney" to="1" />
<map from="melbourne" to="2" />
<map from="brisbane" to="3" />
</mapping>
<rewrite to="/area.aspx?area=${areas:$4|perth}" />
results in "/area.aspx?area=perth"

Related

Fhir , slicing based on the value of an extension

is there a way to define a slicing based on the value of an extension on top of each element of a collection? example: Procedure.bodySite
<element id="Procedure.bodySite">
<path value="Procedure.bodySite" />
<slicing>
<discriminator>
<type value="value" />
<path value="bodySite.extension("http://a/ext").value" />
</discriminator>
<rules value="open" />
</slicing>
</element>
<element id="Procedure.bodySite.extension">
<path value="Procedure.bodySite.extension" />
<slicing>
<discriminator>
<type value="value" />
<path value="url" />
</discriminator>
<rules value="open" />
</slicing>
</element>
<element id="Procedure.bodySite.extension:myExtension">
<path value="Procedure.bodySite.extension" />
<sliceName value="myExtension" />
<type>
<code value="Extension" />
<profile value="http://a/ext" />
</type>
</element>
<element id="Procedure.bodySite:sliceBodySite">
<path value="Procedure.bodySite" />
<sliceName value="sliceBodySite" />
<max value="1" />
</element>
<element id="Procedure.bodySite:sliceBodySite.text">
<path value="Procedure.bodySite.extension" />
<fixedBoolean value="true" />
</element>
the result is : Unable to resolve discriminator in definitions: bodySite.extension('http://a/ext').value
so what is the problem here?
You can use .extension("url") as part of the path in a discriminator. So you can slice by value with a discriminator path of:
bodySite.extension("http://your/extension/url/here").value

how to delete all the line items from the file after the first one

I need to delete all the line items <LineItem> from the file which does not suffice with this requirements:
elements in Line Item : <LineItemNumber V="00000000000000000010" /> and <PurchaseOrderNumber V="0100230946|00010" /> have to be matched, another words in integer Line Item Number would be 10 and Purchase order number after pipe line | would be 10. we need to have only one those line Items which are matching this requirement. Sorry, i'm really bad at describing.
<Transmission>
<InterchangeUsageIndicator V="T" />
<Groups>
<Group>
<GroupSenderID V="CCC" />
<TotalNumberOfShipmentsInGroup V="000005" />
<Documents>
<Document>
<DocumentHeader>
<InvoiceChargeType V="T" />
<DocumentType V="ORDER" />
<DocumentProcessingCode C="00" />
<BOLNumber V="BOL2309460180582136" />
<AlternateQuantities>
<AlternateQuantity Quantity="12.0" UOM="PK" UOMType="SQ" Characteristic="" />
</AlternateQuantities>
<Buyer Name="" Q="ZP" ID="COUSPO001">
<AlternateIDs />
</Buyer>
<Seller Name="" Q="2" ID="CNTR">
<AlternateIDs />
</Seller>
<Parties>
<Party PartyType="SF">
<Name V="SHA" />
<LocationID Q="" ID="" />
<AlternateLocationIDs>
<LocationID Q="" ID="SHA" />
</AlternateLocationIDs>
<City V="Shanghai" />
<Country V="CN" />
<LocationPurpose V="" />
</Party>
<Party PartyType="ST">
<Name V="LEB" />
<LocationID Q="" ID="" />
<AlternateLocationIDs>
<LocationID Q="" ID="LEB" />
</AlternateLocationIDs>
<City V="Lebanon" />
<Country V="TN" />
<LocationPurpose V="" />
</Party>
<Party PartyType="VN">
<Name V="YANGZHOU BAOYI SHOES" />
<LocationID Q="" ID="4100000423" />
<AlternateLocationIDs />
<City V="JIANGSU" />
<Country V="CN" />
<LocationPurpose V="" />
</Party>
</Parties>
<DateReferences>
<DR Type="D" Q="ETA" Date="2019-12-19" />
<DR Type="D" Q="EST" Date="2019-11-28" />
</DateReferences>
<ReservedReferences>
<RR Type="R" Q="K6" V="86|SEAL230946" />
<RR Type="R" Q="V3" V="VYG230946|BKG230946" />
</ReservedReferences>
</DocumentHeader>
<Vessel VesselName="VSL230946" VesselNumber="" VesselCountryOfRegistration="" VesselRegistrationNumber="" />
<Equipments>
<Equipment Initial="CNTR" Number="230946" Length="0" Type="" TotalContainerVolume="52.06" />
</Equipments>
<LineItems>
<LineItem>
<LineItemNumber V="00000000000000000010" />
<LineItemType C="LI" />
<TransportationServiceCode Code="" />
<PurchaseOrderNumber V="0100230946|00010" />
<AdditionalReferenceNumber V="" />
<DescriptionMarksAndNumbers>
<CommodityCode Q="" C="M9160" />
<BuyerProductID V="" />
</DescriptionMarksAndNumbers>
<BilledRatedAsQuantity V="0.0" UOM="PA" />
<LadingQuantity V="0.0" UOM="PA" />
<LineItemTotalAmount V="0.0" />
<LineItemWeight V="0.00" />
<LineItemVolume V="0.00" />
</LineItem>
<LineItem>
<LineItemNumber V="00000000000000900001" /> //this one would not work,because it is 900001
<LineItemType C="LI" />
<LineItemSubType C="SCH" />
<TransportationServiceCode Code="" />
<PurchaseOrderNumber V="0100230946|00010" />
<AdditionalReferenceNumber V="" />
<DescriptionMarksAndNumbers>
<CommodityCode Q="" C="M9160" />
<BuyerProductID V="" />
</DescriptionMarksAndNumbers>
<BilledRatedAsQuantity V="24.0" UOM="PA" />
<LadingQuantity V="24.0" UOM="PA" />
<LineItemTotalAmount V="0.0" />
<UserDefinedReferences>
<UDR Type="U" Q="CR" V="22859470896|001|0001" Description="" />
<UDR Type="U" Q="S6" V="|3|20" Description="" />
<UDR Type="U" Q="19" V="M9160|USDS|0001" Description="" />
</UserDefinedReferences>
<LineItemWeight V="2959.54" />
<LineItemVolume V="104.12" />
</LineItem>
<LineItem>
<LineItemNumber V="00000000000000900002" />
<LineItemType C="LI" />
<LineItemSubType C="SCH" />
<TransportationServiceCode Code="" />
<PurchaseOrderNumber V="0100230946|00010" />
<AdditionalReferenceNumber V="" />
<DescriptionMarksAndNumbers>
<CommodityCode Q="" C="M9160" />
<BuyerProductID V="" />
</DescriptionMarksAndNumbers>
<BilledRatedAsQuantity V="24.0" UOM="PA" />
<LadingQuantity V="24.0" UOM="PA" />
<LineItemTotalAmount V="0.0" />
<UserDefinedReferences>
<UDR Type="U" Q="CR" V="22859470902|001|0002" Description="" />
<UDR Type="U" Q="S6" V="|3.5|20" Description="" />
<UDR Type="U" Q="19" V="M9160|USDS|0001" Description="" />
</UserDefinedReferences>
<LineItemWeight V="2959.54" />
<LineItemVolume V="104.12" />
</LineItem>
I tried to start on LINQ: this is where I got so far:
try {
var xDoc = XDocument.Parse(msg.Body);
var xDocument = xDoc.Root.XPathSelectElement("Groups/Group/Documents/Document");
var xLineItems = xDocument.XPathSelectElements("LineItems/LineItem");
var poNumbers = xLineItems.Select(e => (string)e.Element("PurchaseOrderNumber").Attribute("V")).Distinct();
foreach (var poNumber in poNumbers) {
}
msg.Body = xDoc.ToString();
I believe you would like to Delete all LineItem where LineItemNumber!=10 and PurchaseOrderNumber after the Pipe NOT equals 10. You could use Linq to filter the elements that match the purpose and use the Remove method to deletes the selected nodes.
var xDoc = XDocument.Parse(xml);
xDoc.Descendants("LineItem")
.Where(x=> Convert.ToInt32(x.Element("LineItemNumber").Attribute("V").Value)!=10
&& Convert.ToInt32(x.Element("PurchaseOrderNumber").Attribute("V").Value.Split('|')[1])!=10
).Remove();
var result = xDoc.ToString();

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.

extract with multiple predicates and multiple predicates

I want to extract information from the jms-bus node. Specifically the busid,
//[local-name()='jms-bus'][#busid=//[local-name()='jms-listener']/#busidref]/#busid matches perfectly and returns quickstartGwChannel and quickstartESBChannel if the have matching providers and services.
However, I want to return the jms-bus(s) where it has a jms-listener is-gateway='true'
I am not sure where to put the 'and' clause. When I put it at the beginning //*[local-name()='jms-listener]/[#is-gateway='true']and .... it returns a boolean.
I need to extract from this xml
<providers>
<jms-provider name="JBossMQ" connection-factory="ConnectionFactory">
<jms-bus busid="quickstartGwChannel">
<jms-message-filter
dest-type="QUEUE"
dest-name="queue/quickstart_helloworld_Request_gw"
/>
</jms-bus>
<jms-bus busid="quickstartEsbChannel">
<jms-message-filter
dest-type="QUEUE"
dest-name="queue/quickstart_helloworld_Request_esb"
/>
</jms-bus>
</jms-provider>
</providers>
<services>
<service
category="FirstServiceESB"
name="SimpleListener"
description="Hello World">
<listeners>
<jms-listener name="JMS-Gateway"
busidref="quickstartGwChannel"
is-gateway="true"
/>
<jms-listener name="helloWorld"
busidref="X12"
is-gateway="false"
/>
</listeners>
<actions mep="OneWay">
<action name="action1"
class="org.jboss.soa.esb.samples.quickstart.helloworld.MyJMSListenerAction"
process="displayMessage"
/>
<action name="action2" class="org.jboss.soa.esb.actions.SystemPrintln">
<property name="printfull" value="false"/>
</action>
<!-- The next action is for Continuous Integration testing -->
<action name="testStore" class="org.jboss.soa.esb.actions.TestMessageStore"/>
</actions>
</service>
</services>
Something like this:
//*[local-name()='jms-bus']
[#busid=//*[local-name()='jms-listener']
[#is-gateway='true']/#busidref]/#busid
or
//*[local-name()='jms-bus']
[#busid=//*[local-name()='jms-listener' and #is-gateway='true']/#busidref]/#busid

String restriction within protobuf

Can I represent this XSDSchema enumeration/String restriction within a protobuf enum?
<s:element maxOccurs="1" minOccurs="1" name="Condition">
<s:simpleType>
<s:restriction base="s:string">
<s:enumeration value="EQ" />
<s:enumeration value="NE" />
<s:enumeration value="GT" />
<s:enumeration value="LT" />
<s:enumeration value="GE" />
<s:enumeration value="LE" />
<s:enumeration value="LK" />
<s:enumeration value="=" />
<s:enumeration value="!=" />
<s:enumeration value=">" />
<s:enumeration value="<" />
<s:enumeration value="=>" />
</s:restriction>
</s:simpleType>
</s:element>
.proto enums are named integers, but note that the last few names will barf. You would need to tweak the names in your .proto / DTO layer, but it would a pain to have to disambiguate between "EQ" and "=", "LE" and "<"
But you could map something similar in .proto, sure.
If you store a string that would work, but will be more bytes. Not many more (1 byte for the string length plus 1-4 bytes for the char-data, versus 1 byte for the enums).

Resources