Config Transform, Unrecognized XML Namespace After Transformation - asp.net

One of our config files is being transformed oddly.
Base Config
<?xml version="1.0"?>
<configuration >
</configuration>
Release Config (as it is in the project, truncated for brevity)
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore xdt:Transform="Insert">
<contentSearch>
<configuration>
<indexes>
<index id="sitecore_web_index">
<param desc="core" patch:instead="param[#desc='core']">#{IndexEnvironment}#_web_index</param>
</index>
</indexes>
<indexes role:require="Standalone or ContentManagement">
<index id="sitecore_master_index">
<param desc="core" patch:instead="param[#desc='core']">#{IndexEnvironment}#_master_index</param>
</index>
After a build is run, the output of the final config looks very strange:
Post build
<?xml version="1.0"?>
<configuration>
<sitecore>
<contentSearch>
<configuration>
<indexes>
<index id="sitecore_web_index">
<param desc="core" d7p1:instead="param[#desc='core']" xmlns:d7p1="http://www.sitecore.net/xmlconfig/">ASHQA_web_index</param>
</index>
</indexes>
<indexes d5p1:require="Standalone or ContentManagement" xmlns:d5p1="http://www.sitecore.net/xmlconfig/role/">
<index id="sitecore_master_index">
<param desc="core" d7p1:instead="param[#desc='core']" xmlns:d7p1="http://www.sitecore.net/xmlconfig/">ASHQA_master_index</param>
</index>
Notice how the patch and role definitions are changed to d7p1 and d5p1 respectively.
While this is valid XML, it is causing issues in our application which parses the XML and looks for the proper terms of patch and role.

TL;DR
Any namespaces required in a transformed config, need to be defined in the base config.
Base Config Updates
<?xml version="1.0"?>
<configuration xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:patch="http://www.sitecore.net/xmlconfig/">
</configuration>
Even though the base config does not rely on these namespaces, they do not carry over properly if they are not included. This also cleans up the output of the resulting config as expected:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<configuration>
<indexes>
<index id="sitecore_web_index">
<param desc="core" patch:instead="param[#desc='core']">#{IndexEnvironment}#_web_index</param>
</index>
</indexes>
<indexes role:require="Standalone or ContentManagement">
<index id="sitecore_master_index">
<param desc="core" patch:instead="param[#desc='core']">#{IndexEnvironment}#_master_index</param>
</index>

Related

Alfresco custom subtypes for cm:folder not working

I tried to to create a new folder type, that inherits everything from cm:folder, so I created an xml file for myModel.xml under tomcat/shared/classes/alfresco/extension/models, and added the following content to it:
<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0 modelSchema.xsd" -->
<model name="my:custmodel"
xmlns="http://www.alfresco.org/model/dictionary/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description>custom folder test</description>
<author>Max Mustermann</author>
<published>2015-11-24</published>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
</imports>
<namespaces>
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
<namespace uri="http://www.alfresco.org/model/rendition/1.0" prefix="rn"/>
<namespace uri="http://www.alfresco.org/model/exif/1.0" prefix="exif"/>
<namespace uri="http://www.alfresco.org/model/audio/1.0" prefix="audio"/>
<namespace uri="http://www.alfresco.org/model/webdav/1.0" prefix="webdav"/>
<namespace uri="http://www.example.com/model/content/1.0" prefix="my" />
</namespaces>
<types>
<type name="my:folder1">
<title>folder1</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
<type name="my:folder2">
<title>folder2</title>
<parent>cm:folder</parent>
<archive>true</archive>
</type>
</types>
then I added the following line to tomcat/shared/classes/alfresco/extension/custom-model-context.xml
<value>alfresco/extension/models/myModel.xml</value>
and finally in tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml:
<type name="cm:folder">
<subtype name="my:folder1" />
<subtype name="my:folder2" />
</type>
Now the under details->change Typ, my subtypes appear, but when I try to apply them I get "cannot change type of document ..."
Your model file name in context file is mentioned as
<value>alfresco/extension/models/custModel.xml</value>
in your description you are saying name as "myModel.xml" is that a typo? Otherwise your file entries looks okey. Hope you are placing those entries properly.
This entry
<namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
should be part of <imports> tag not <namespaces>
Something like this
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>

Websphere - Set content type/charset of external resource

I have mapped static content (html) to external directory. When I request html file over HTTP, it returned content type/charset Windows-874.
Content-Type:text/html; charset=Windows-874
I would like to change it to
Content-Type:text/html; charset=UTF-8
How can I change it in 'ibm-web-ext.xml'? Or I have to change it in other configurations of Websphere?
Here is my ibm-web-ext.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
version="1.0">
<file-serving-attribute name="extendedDocumentRoot" value="D:/XXX/content/" />
<reload-interval value="3"/>
<auto-encode-requests value="false"/>
<auto-encode-responses value="false"/>
<enable-directory-browsing value="false"/>
<enable-file-serving value="true"/>
<pre-compile-jsps value="false"/>
<enable-reloading value="true"/>
<enable-serving-servlets-by-class-name value="false" />
</web-ext>

What is a (the?) minimal logger.properties that turns off all logging?

I have an application that uses log4cxx internally, with dozens of loggers. What is a minimal logger.properties that I can setup to turn off all logging output?
In particular I'm getting a warning like (no properties file present):
log4cxx: No appender could be found for logger (FileSource).
log4cxx: Please initialize the log4cxx system properly.
FileSource is a class that uses log4cxx.
My goal is to preclude all log4cxx output at runtime.
This should do it:
<?xml version="1.0" encoding="UTF-8" ?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<root>
<priority value="OFF" />
</root>
</log4j:configuration>
A simple logger.properties that logs to standard out could look like below:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- add attribute debug="true" to log4j:configuration tag to see how logger reads it's configuration. -->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c (%F:%M:%L) - %m%n" />
</layout>
</appender>
<root>
<priority value="DEBUG" />
<appender-ref ref="ConsoleAppender"/>
</root>
</log4j:configuration>

How to extract variable from SOAP request in Edge policy?

Here's my policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="extract-operation">
<DisplayName>extract-operation</DisplayName>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Source clearPayload="true">request.content</Source>
<VariablePrefix>apigee</VariablePrefix>
<XMLPayload stopPayloadProcessing="false">
<Namespaces>
<Namespace prefix="soapenv">http://schemas.xmlsoap.org/soap/envelope/</Namespace>
</Namespaces>
<Variable name="operation" type="string">
<XPath>/soapenv:Envelope/soapenv:Body</XPath>
</Variable>
</XMLPayload>
</ExtractVariables>
In trace tool I see that request.content resolves fine and shows the content, but I was expecting apigee.operation to be populated with the contents of . What am I doing wrong?
Fixed Policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="extract-operation">
<DisplayName>extract-operation</DisplayName>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Source clearPayload="true">request.content</Source>
<XMLPayload stopPayloadProcessing="false">
<Namespaces>
<Namespace prefix="soapenv">http://schemas.xmlsoap.org/soap/envelope/</Namespace>
</Namespaces>
<Variable name="operation" type="nodeset">
<XPath>/soapenv:Envelope/soapenv:Body</XPath>
</Variable>
</XMLPayload>
</ExtractVariables>
If you know the Xpath you don't really need the scema and then you take on more variable out of the equation (ie whether the schema is valid). Then you could just reference //Body (or wherever it is in the xml)

Unity Interception MethodSignatureMatchingRule could not be resolved

Im using Unity (3.0) interception to add some crosscutting concerns to my application. Somehow I can't use the MethodSignatureMatchingRule in my configuration getting this error message:
{"The type name or alias MethodSignatureMatchingRule could not be resolved. Please check your configuration file and verify this type name."}
My configuration:
<?xml version="1.0"?>
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<sectionExtension type="Microsoft.Practices.Unity.InterceptionExtension.Configuration.InterceptionConfigurationExtension, Microsoft.Practices.Unity.Interception.Configuration" />
<alias alias="singleton" type="Microsoft.Practices.Unity.ContainerControlledLifetimeManager, Microsoft.Practices.Unity" />
<containers>
<container name="MyContainer">
<extension type="Interception"/>
<interception>
<policy name="EhabAspect">
<matchingRule name="MethodSignatureMatchingRule" type="MethodSignatureMatchingRule">
<constructor>
<param name="methodName" value="Receive" type="string"/>
</constructor>
</matchingRule>
<callHandler ... (omitted)
</policy>
</interception>
<register type="IMyClass" mapTo="MyClass">
<lifetime type="singleton" />
<interceptor type="InterfaceInterceptor"/>
<policyInjection/>
</register>
</container>
</containers>
</unity>
The same configuration with the NamespaceMatchingRule works fine.
My assembly contains a reference to
Microsoft.Practices.EnterpriseLibrary.Common
Microsoft.Practices.Unity
Microsoft.Practices.Unity.Configuration
Any suggestions?
I was facing the same problem here. I solved using the full qualified name of the of the class.
<matchingRule name="AuthorizationMethod" type="Microsoft.Practices.Unity.InterceptionExtension.MethodSignatureMatchingRule, Microsoft.Practices.Unity.Interception">
<constructor>
<param name="methodName" value="Authenticate" type="string"/>
<param name="parameterTypeNames" dependencyName="EmptyArray"/>
</constructor>
</matchingRule>

Resources