Preventing special characters in tridion component field and changes in schema - xsd

In component, I should not allow any special characters to be entered. When I try to enter a comma, it should suggest "no special characters allowed". Please suggest where do I make the necessary changes. I tried making some changes in schema(source) like adding but not working.
<xsd:element name="FileName">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[a-zA-Z0-9_.' !##$%^*()_+={}|/:;,>?/`~ ]"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

What you're asking for is a custom validation that may not be best accommodated via the Schema (XSD). You may be able to do it there via a feature called facets. Check the sdllive docs for examples. You can make it give you validation error messages, but you cannot customize the messages themselves, and they are ugly and scary looking for the average content editor.
The other approaches are:
1) develop a custom event via the Event System. This is the easiest option IMO. Simply throw an exception with a custom message on a Compenent Save event in the Init phase.
2) develop a custom GUI extension to do the validation. This IMO is more work than the above, but is achievable.

Related

Use liferay-ui:asset-categories-selector tag to offer one vocabulary only

I'm developing a Liferay portlet supposed to offer a way of categorizing its content. I created multiple vocabularies (e.g. frogs, apes, birds).
In the view of THIS portlet I want to offer the categories of the "frogs"-vocabulary only. I know I could write some code to read the categories contained in the vocabulary to offer them in a combo-box.
But, isn't there a way of convincing the built-in liferay-ui:asset-categories-selector-tag to show one vocabulary only? Or may be there's some other tag? (I'm stuck here.)
Here's my current code that lists all vocabularies:
<liferay-ui:asset-categories-selector
className=" <%= JournalArticle.class.getName() %>"
/>
Unfortunately this taglib's documentation is quite tumbleweed. You might need to look into the implementation for the actual content of the attribute, but curCategoryIds might be a good choice to start trying out if this is foreseen.
Alternatively it might be worth creating another tag (based on this one, in a new taglib) - if you do this, you might want to file an issue or feature request and contribute it back into the liferay-ui taglib.

Using <xs:appinfo> to specify version information

I have found few examples of "standard" usage of <xs:appinfo>. This one is interesting: http://docstore.mik.ua/orelly/xml/schema/ch15_01.htm#ch15-77057, however I would like to provide info like "used since v1.3" or "deprecated since v1.1". Any suggestion?
Both <xs:documentation> and <xs:appinfo> allow as children any other XML elements without limitations (along with just text).
The XSD language does not specify what exactly that extra XML and its meaning might be.
It purpose is just to allow for anyone to extend particular schema/components with
some extra (structured) information, which could be processed/used further automatically.
So, it is completely up to you how to design that extra XML (which would extend your documentation) and how to process and use it.
For that matter, one usage of such extra XML is to format the annotation text with HTML. In that case, that custom XML will be simply XHTML.

I need my BizTalk map to stop converting xml:lang to ns1:lang

I have a map in BizTalk 2009 that is converting some data into an XML document to be sent on to another system. The target schema includes some elements with xml:lang attributes. BizTalk generates those as ns1:lang. The target system requires that the prefix xml be used.
Here is a simplified example to show what BizTalk is doing:
sample.xsd
<xs:schema targetNamespace="http://example.com/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation="common.xsd"
namespace="http://www.w3.org/XML/1998/namespace" />
<xs:element name="example">
<xs:complexType>
<xs:attribute ref="xml:lang" />
</xs:complexType>
</xs:element>
</xs:schema>
common.xsd
<xs:schema xmlns:xml="http://www.w3.org/XML/1998/namespace"
targetNamespace="http://www.w3.org/XML/1998/namespace"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attribute name="lang" type="xs:language" />
</xs:schema>
Example of map output
<ns0:example xmlns:ns0="http://example.com/"
xmlns:ns1="http://www.w3.org/XML/1998/namespace"
ns1:lang="en-US" />
Is there some way to convince BizTalk to use the xml prefix?
As far as I know, there is no builtin way for achieving this.
There are, however, two solutions that I can see:
Use a Custom XML StyleSheet
If you right-clik on the map and look carefully in the generated xsl stylesheet, you'll see a XML namespace declaration like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://www.w3.org/XML/1998/namespace"
...
>
...
<xsl:attribute name="ns1:lang">
...
This is the default behaviour of the BizTalk mapper and you cannot do anything about it. However, if you proceed to extract the generated XSLT and use this as the backend for your map, you can change this declaration to match the expected outcome.
First, copy the stylesheet to the location of your project.
Include this stylesheet as a file in your BizTalk project
Update the stylesheet, so that the namespace declaration and the matching attribute prefix are correct.
The resulting xsl stylesheet looks like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
...
>
...
<xsl:attribute name="xml:lang">
...
Now you can use this custom stylesheet as a backend for the map.
In Visual Studio, open the map.
Click anywhere on a blank space in the BizTalk designer surface.
In the map properties, locate the Custom XSL Path and specify the location of your custom stylesheet.
Use a Custom Pipeline Component
What you're after is that the message is correct for your target recipient. So the idea is to change the offending namespace prefix as part of sending the message outside BizTalk. The transformation happens during the processing of the send pipeline.
Nic Barden has blogged and provided some source code about this here. You can use his sample as the basis for performing replacement of namespace prefixes, rather than replacing namespaces themselves.
I strongly encourage you to check out the whole series of posts he's done about Developing Streaming Pipeline Components. Nic has made an extensive and thorough job of describing all that's needed to author robust and enterprise-class pipeline components.
Part 1
Part 2
Part 3
Part 4
Part 5
The easier way to do it and have everything work is to just add the namespace declaration at the beginning of the schema definition like this.
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xml="http://www.w3.org/XML/1998/namespace">
<xs:import schemaLocation="xml.xsd" namespace="http://www.w3.org/XML/1998/namespace" />
In addition to Maxime's suggestions, here are the other possibilities I've found:
Ignore it and hope that the vendor’s API will take it.
I don’t think this will work. When I test the map, BizTalk gives me this error:
Output validation error: Prefix 'ns1' cannot be mapped to namespace name reserved for "xml" or "xmlns".
Hello, BizTalk!? You’re the one who decided to use ns1. Don’t complain about it to me!
Use an XSL-based script functoid to force the output.
This is based on the suggestion I received on the BizTalk forums. It requires that we fudge the output schema to use a dummy attribute that gets replaced with the xml:lang attribute by the functoid.`
Add a search/replace expression
Take the orchestration that calls the map and add an expression after it that would take the XML we’re sending to the vendor and run it through a search/replace regex to fix the namespace prefixes.

Determine the property name in a SharePoint Webpart for XML

I'm employing a custom webpart that is made by an unaffiliated third party. I've created a feature which adds this webpart to a page. It's working mostly fine, except that I can't figure out the name of a specific property that needs to be defined. I tried obvious ones that match the display name on the tool pane view, adding the company's name in front of said display name, and many similar permutations. All of which to no avail. I would much prefer to include the property to the feature, as this will be necessary to deploy across multiple sites in the future. Manually configuring it every time will be a pain for my client.
The short, obvious answer is "Ask the third party". This can potentially work, particularly for this specific one (it is a CodePlex webpart and the author has posted a comment as recent as last week). But my experience with previous third party solutions has been less than optimal, usually even getting no response until they ask me three weeks later if I still like their product. So, since this is not always a reliable method to obtain this information, I was thinking the best option is to find out a way to figure out the name of properties in a webpart that I can use not just with this particular one, but in all future situations.
I did check out this earlier question which addresses a similar topic. However, I don't have access to the class for the webpart so I can't just find a convenient property in the code to modify. Or, at least, if I do have access to it in some fashion, I'm certainly unaware of it.
Thank you in advance!
From what I understand, you are trying to set a certain webpart property for which you do not know the corresponding XML attribute name.
Did you try to export the web part? One possible check might be to try to export the webpart to see what properties come up in the webpart XML. If it is a common property, chances are the webpart XML will have that property already defined with no value e.g.
<data>
<properties>
<property name="Your property Name" type="yourType"></property>
<properties>
</data>
To export the webpart, go to Edit Page mode, click the down arrow on the webpart and choose Export.
Also, if you have the webpart code in a dll, can you use reflector to open it and see what properties are being set in code?
Hope this helps.

Fields not present in custom Content Type (inherited from "Page") SharePoint

so I want to deploy a custom Content Type based on "Page" by Feature. The deployment of the Content Types works fine -- the custom Content Types is created based on "Page".
The thing that is missing are the FieldRefs: The Fields I reference in the FieldRefs Tag are not showing up in my deployed Content Type.
My Elements.xml looks like ...
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field Type="Text"
DisplayName="PlantName"
Required="FALSE"
Group="Custom Columns"
ID="{2068B882-8349-4a7f-BA3A-60BE60DEFF9A}"
StaticName="PlantName"
Name="PlantName" />
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900A96BBF2C61EC4534A7654CEF00B72A9D"
Name="PlantDocument"
Group="Custom Content Types"
Description="PlantDocument"
Hidden="FALSE"
Version="0">
<FieldRefs>
<FieldRef ID="2068B882-8349-4a7f-BA3A-60BE60DEFF9A"
Name="PlantName" />
</FieldRefs>
</ContentType>
</Elements>
Can anyone tell me why "PlantName" is not present in my Content Type?
THANKS A LOT FOR ALL HELP!
I was having a similar problem, and after some experimentation I found that comments in the XML cause havoc.
This works fine
<FieldRefs>
<FieldRef ID="{4B9D42FA-8081-49AB-9F89-72FAB3C6609C}"/>
</FieldRefs>
This does not work
<FieldRefs>
<!-- My field comment -->
<FieldRef ID="{4B9D42FA-8081-49AB-9F89-72FAB3C6609C}"/>
</FieldRefs>
I will refrain from commenting on this as I may get upset and stop working.
I'm not sure if I've understood your issue totally but it sounds similar to something I've seen before.
I'm going to assume you've checked all the obvious things like your schema definition and wether you're deactivating and activating the your content type feature after deploying your schema..
Once you add a content type to your site, the likely scenario is that you create an instance of a page/list item based on that content type somewhere in your site. In my case it was two sub sites down. This worked fine for me. Once I updated my content type (by adding in a new field), although I could see the content type change spearing in the content type gallery but I couldn't see the change go through to the sub site where I had created a page based on my content type. This is because, when you create an instance of a item based on a certain content type, the sub site creates a cached copy of that content type in its current condition.
Later when you make changes to the content type, the cached copy in the subsite does NOT get updated. This isn't the most obvious thing in the world.
Maybe you cannot see the fields appearing in the sub site but they do exist in your site columns and the your root content type has been updated correctly.
If this is your issue then you need to perform, what we call a 'content-type push down'. To do this you can either download Gary Lapointe's stsadm command which you'll have to run through the command prompt (I hear this is risky in some scenarios). You can also do this manually but sorry, I can't remember exactly how this is done. You have to delete all instances based on your content type and try again. Quite a painful little task.

Resources